Alternatively If the array is large then } is space efficient
            swap =: 4 : '0 0$ ".y,''=:(x{'',y,'')(|.x)}'',y'
            list =: 10...@$100
            10{.list
59 61 1 92 37 94 26 96 6 2
            7!:2'0 4 swap ''list'''  NB. space used
4032
            10{.list
37 61 1 92 59 94 26 96 6 2

            sw=: <@~...@[ C. ]
            7!:2' list=: 0 4 sw list'
201327808

Note that the only space efficient form of
such usage of } is  y =. x m} y
(http://jsoftware.com/help/dictionary/special.htm)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to