Re: [Factor-talk] conditional combinator proposal

2011-10-01 Thread Samuel Tardieu
2011/10/1 Slava Pestov sl...@factorcode.org Hi Michele, On Fri, Sep 30, 2011 at 2:53 PM, Michele Pes mp8...@rambler.ru wrote: To achieve this, I wrote this word: : when-drop ( obj question-quot: ( obj -- ? ) true-quot: ( obj -- ) -- ) -rot dupd call swapd [ call ] [ 2drop ] if ;

[Factor-talk] conditional combinator proposal

2011-09-30 Thread Michele Pes
Hi to all! While writing my little factor programs, I often find a situation in which I have an object, I test it and if test is ok then some action is performed on it, else it is simply dropped. Ex.: (obj on top of stack) dup test-condition [ do something with obj ] [ drop ] if I think this

Re: [Factor-talk] conditional combinator proposal

2011-09-30 Thread Joe Groff
On Sep 30, 2011, at 2:53 PM, Michele Pes wrote: Hi to all! While writing my little factor programs, I often find a situation in which I have an object, I test it and if test is ok then some action is performed on it, else it is simply dropped. Ex.: (obj on top of stack) dup

Re: [Factor-talk] conditional combinator proposal

2011-09-30 Thread Slava Pestov
Hi Michele, On Fri, Sep 30, 2011 at 2:53 PM, Michele Pes mp8...@rambler.ru wrote: To achieve this, I wrote this word: : when-drop ( obj question-quot: ( obj -- ? ) true-quot: ( obj -- ) -- )    -rot dupd call swapd [ call ] [ 2drop ] if ; inline Here is a simpler version that doesn't use