Thank you very much for both answers.
They both are very instructive.
This one is really amazing though:
>
> ```
> TUPLE: array-ref index array ;
> C: array-ref
> : >array-ref< ( array-ref -- index array )
> [ index>> ] [ array>> ] bi ;
> : get-ref ( array-ref -- elt )
> >array-ref< nth ;
On Mon, Mar 12, 2012 at 6:00 AM, nicolas.o...@gmail.com
wrote:
> I quite like the style of something along the lines of:
>
> : swap-element ( i1 array1 i2 array2 -- )
> [ [ nth ] 2keep ] 2bi@ [ set-nth ] 2 smart-apply ;
>
> because it shows the dataflow better than with lexical variables.
What about using local only to implement the difficult stack shuffling
that you named "" ?
:: ( a b c d e h -- d b c a e h )
d b c a e h ;
: swap-element ( i1 array1 i2 array2 -- )
[ [ nth ] 2keep ] 2bi@ [ set-nth ] 2 smart-apply ;
And you could name "" "(swap-element)"
Dear all,
I am starting to learn Factor as my first concatenative language (from
a FP background) and enjoy it very much.
However, when trying to write simple words I get stuck on how to best
express dataflow.
As a (very very simple) example, I am trying to write a word
: swap-element ( i1 arra