> Eg Behead has a dyadic form
> Drop }. but Curtail does not ... are there
> some better (future) plans
> for a dyadic curtail 

Dyadic  }.  can be used to curtail multiple items.  Use a negative LHA.  For 
example:

           _3 }. 1 2 3 4 5
        1 2


>  back=: back, {: stack
>  stack=: }: stack

You can split a list of items into two variables in a single operation like 
this:

           stack =. 1 2 3 4 5
           'stack back' =. _2 (}. ; {.)  stack
           
           stack
        1 2 3
           back
        4 5

I don't know what swap does in Forth, but is this what you're looking for?

           swap =. ,~
           1 swap 2 
        2 1

Or are you trying to reorder your stack?

           swap =: (<_2 _1)&C.
           swap ;: 'bottom middle top'
        +------+---+------+
        |bottom|top|middle|
        +------+---+------+
           
Or maybe you like the old fashioned way:

           swap =. 4 : 'x ,: y =. y 22 b. x =. x 22 b. y =. y 22 b. x'&.(a. i. 
3!:1"1)
           1 swap 2
        2 1

:)


-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to