@@ -3,8 +3,8 @@ use std::collections::{hash_map::Entry, HashMap};
3
3
use ecow:: EcoVec ;
4
4
5
5
use crate :: {
6
- get_ops, types:: push_empty_rows_value, val_as_arr, Array , ArrayValue , Ops , Primitive , SigNode ,
7
- Uiua , UiuaResult , Value ,
6
+ get_ops, grid_fmt :: GridFmt , types:: push_empty_rows_value, val_as_arr, Array , ArrayValue , Ops ,
7
+ Primitive , SigNode , Uiua , UiuaResult , Value ,
8
8
} ;
9
9
10
10
use super :: { monadic:: range, table:: table_impl, validate_size} ;
@@ -256,6 +256,15 @@ fn tuple2(f: SigNode, env: &mut Uiua) -> UiuaResult {
256
256
Array :: new ( shape, data) . into ( )
257
257
} )
258
258
}
259
+ if xs. row_count ( ) == 0 {
260
+ env. push ( if is_scalar {
261
+ 0 . into ( )
262
+ } else {
263
+ xs. shape . insert ( 1 , k) ;
264
+ xs
265
+ } ) ;
266
+ return Ok ( ( ) ) ;
267
+ }
259
268
let scalar = xs. as_nat ( env, "Tuples of scalar must be a natural number" ) ;
260
269
xs = match & xs {
261
270
Value :: Num ( a) => inner ( a, k, f, is_scalar, scalar, env) ?,
@@ -318,7 +327,10 @@ impl<T: ArrayValue> Array<T> {
318
327
return Err ( env. error ( "Combinatorial explosion" ) ) ;
319
328
}
320
329
if combinations > usize:: MAX as f64 {
321
- return Err ( env. error ( format ! ( "{combinations} combinations would be too many" ) ) ) ;
330
+ return Err ( env. error ( format ! (
331
+ "{} combinations would be too many" ,
332
+ combinations. grid_string( false )
333
+ ) ) ) ;
322
334
}
323
335
shape[ 0 ] = combinations. round ( ) as usize ;
324
336
shape. insert ( 1 , k) ;
@@ -436,7 +448,10 @@ impl<T: ArrayValue> Array<T> {
436
448
return Err ( env. error ( "Combinatorial explosion" ) ) ;
437
449
}
438
450
if permutations > usize:: MAX as f64 {
439
- return Err ( env. error ( format ! ( "{permutations} permutations would be too many" ) ) ) ;
451
+ return Err ( env. error ( format ! (
452
+ "{} permutations would be too many" ,
453
+ permutations. grid_string( false )
454
+ ) ) ) ;
440
455
}
441
456
shape[ 0 ] = permutations. round ( ) as usize ;
442
457
shape. insert ( 1 , k) ;
0 commit comments