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 array1 i2 array2 -- ) that swaps two elements with indices i1 and i2 from 2 (aliased or not) arrays. It is very easy to write such a word using lexical variables. However, I have two problems with that: - I am not sure it is the right tool to use or just my brain bringing me back to what I know. - It does not show the symmetries of the dataflow of this word 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. But I can't find something nice to put instead of ????. So, I guess that my question is: how to solve this problem and, more importantly, how to learn to solve this kind of problem by myself? Thank you very much for your help, Best regards, Nicolas. ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 _______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk