On Fri, Apr 29, 2011 at 2:03 PM, Ian Clark <[email protected]> wrote: > My brain's a mess this morning... > > Let foo be a dyadic verb which simply returns i.y with the zero > floated up to position x . > (Forget the cases of x<1 and x>y) > > foo=: 4 : '(1|.i.x) , (x}.i.y)' > 3 foo 9 > 1 2 0 3 4 5 6 7 8
Everyone seems to be giving answers that use amends or takes and drops or even permute. Why, if we can manage this easily with only the operators our fathers have had, that is, iota, comparisions, and arithmetic. :-) foo =: ((~:>:)*>+])i. 3 foo 9 1 2 0 3 4 5 6 7 8 Or, if you also want to abstain from forks and use only delta-defined verbs, then here's the explicit form. foo =: 4 :'(x~:1+z)*z+x>z=.i.y' 3 foo 9 1 2 0 3 4 5 6 7 8 Ambrus ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
