Well, I'll be damned! Thank you for the explanation. Looks like I only missed a `swap` call, and otherwise was on the correct path.
And thank you for the implementation details (1-element array box), it all makes sense now! Appreciate your help, Jon!
20.01.2017, 22:24, "Jon Harper" <jon.harpe...@gmail.com>:
Also, you did create a closure. This is exactly what you want, and the assignments to elt do work, the value is updated in the subsequent calls. (In fact, factor implements local mutable variable by boxing the value in a 1 element array. The array is curried into the quotation).It's actually pretty close to what you wanted, you just swapped the prev and next element in the each2* you wrote. The following has the correct behavior.
:: each2* ( seq quot: ( prev next -- next' ) -- )
seq unclip-slice :> elt! quot '[ elt swap @ elt! ] each ; inline
{ 1 2 3 } [ [ swap . . nl ] keep 10 + ] each2*
1
2
12
3
---=====---
Александр
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk