Various translations going from most literal
to most J-like:
spd=: 4 : 0
((1{f),*/0 2{f) $, 1 0 2|:(f=. x,c%x,1) $, (c=. d+(x|x-0{d=.$y),0){.y
)
spd1=: 4 : 0
(t,x*n) $, 1 0 2|:(x,t,n=.{:$y) $, (x*t=. >.({.$y)%x){.y
)
spd2=: 4 : 0
(t,x*{:$y) $, > |: (x,t)$<"1 (x*t=. >.(#y)%x){.y
)
spd3=: 4 : 0
(t,x*{:$y) $, (|:i.x,t) { (x*t=. >.(#y)%x){.y
)
spd4=: 4 : 0
,./ (x,t) $ (x*t=. >.(#y)%x){.y
)
spdj=: [: ,./ -@>.@(%~#) ]\ ]
spd: literal translation of original APL
spd1: use better names and exploit features
available in some APLs (e.g. SHARP APL)
spd2: bypass having to deal with the # of columns
spd3: another way to bypass the # of columns
spd4: exploit ,./ and $
spdj: most J-like version
What I most dislike about the original APL version
is its lack of a good example. For example, from
3 spd > ;: 'able baker charlie dog echo fred gamma ham india jam ken lambda
michael'
able fred ken
baker gamma lambda
charlieham michael
dog india
echo jam
I would have known immediately what the function
was trying to achieve.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm