Menu

#66 `ew` raises too many exceptions

0.6.5
pending
aditsu
None
2015-11-25
2015-05-14
Dennis
No

[1]2ew raising an invalid slice size exception means you cannot use 2ew if you don't the array length beforehand.

I'd expect 2ew to behave like [_\1>]zW<, so Array Long ew should just return an empty array if the Long is longer than the Array.

Also, negative slice sizes could be used to reverse slices inner order:

[1 2 3]-2ew e# Gives [[2 1] [3 2]]

Discussion

  • Martin Büttner

    Martin Büttner - 2015-06-03

    Here is another generalisation that seems useful and would have saved me a dozen bytes or more just now:

    [[1 2 3]
     [4 5 6]
     [7 8 9]] [2 2] ew
    

    which would give

    [[[[1 2][4 5]] [[2 3][5 6]]]
     [[[4 5][7 8]] [[5 6][8 9]]]]
    

    That is [m n] would give a grid of all m x n sub-blocks. This would easily generalise to arbitrary dimensions, but it seems most useful for processing ASCII grids.

     
  • Sp3000

    Sp3000 - 2015-11-06

    Here's another use case for Array Long ew giving empty array when Long is larger than the length of the Array: link

     
  • aditsu

    aditsu - 2015-11-25
    • status: open --> pending
    • assigned_to: aditsu
     
  • aditsu

    aditsu - 2015-11-25

    I've implemented the "return empty array if the number is too large" part

     

Log in to post a comment.