Much neater than what I was about to offer, unless Raoul needs to
specify the fill,
in which case, this alternative rather minimal amendment is worth
consideration:
($!._ ~2,~>.@-:@#) i.7
0 1
2 3
4 5
6 _
cf
_2]\ i.7
0 1
2 3
4 5
6 0
Also, the time and space performance _might_ be important for large inputs:
ts' $ _2]\ list ' [list =: i.100000
0.000618 1.04986e6
ts'($!._ ~2,~>.@-:@#) list'
2.7e_6 2304
Cheers,
Mike
On 16/05/2020 15:57, 'Rob Hodgkinson' via Programming wrote:
You could try Infix … here with NuVoc link…
https://code.jsoftware.com/wiki/Vocabulary/bslash#dyadic
x u\ y where x is eg _2 means apply very b to successive pairs (_ for
non-overlapping).
_2 ]\ 1 2 3 4 5 6
1 2
3 4
5 6
_2 ]\ 1 2 3 4 5 6 7
1 2
3 4
5 6
7 0
_2 <\ 1 2 3 4 5 6
┌───┬───┬───┐
│1 2│3 4│5 6│
└───┴───┴───┘
HTH…/Rob
On 17 May 2020, at 12:42 am, Raoul Schorer <raoul.scho...@gmail.com> wrote:
Hello,
I am convinced that this must be trivial, but I wasn't able to find in the
documentation how to reshape a list to a table without manually extracting the
length.
in summary, is there a more direct way of doing:
lst =. i. 6
((2,~2%~#) $ ]) lst
for a list of arbitrary length?
Thanks!
Raoul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm