Hi, all! I'm a newbie trying to understand Factor.
Today I wrote a function called ndrop. The idea is that if you have nine pieces of junk on the stack you could write "9 ndrop" to get rid of them. Here's my attempted solution: USING: kernel math ; IN: ndrop ! Drop n items from the stack (plus the "n" itself). : ndrop ( ..n -- ) [ dup 0 > ] [ 1 - swap drop ] while drop ; When I try to run it I get some error messages that I need your help understanding: The word ndrop cannot be executed because it failed to compile The input quotations to “while” don't match their expected effects Input Expected Got [ dup 0 > ] ( ..a -- ..b ? ) ( x -- x x ) [ 1 - swap drop ] ( ..b -- ..a ) ( x x -- x ) Regarding the first line: Input Expected Got [ dup 0 > ] ( ..a -- ..b ? ) ( x -- x x ) I read it as "a boolean is expected at the stack top, but some other value was found". How can that be if the last function is ">", and it does return a boolean. Regarding the second line: Input Expected Got [ 1 - swap drop ] ( ..b -- ..a ) ( x x -- x ) I read it as "you can't reduce the stack size inside the loop body". Why not? Any general advice would be highly welcome as well. ---=====--- Александр ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk