Re: [Factor-talk] conditional combinator proposal
2011/10/1 Slava Pestov > Hi Michele, > > On Fri, Sep 30, 2011 at 2:53 PM, Michele Pes 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 locals: > > : when-drop ( obj question-quot: ( obj -- ? ) true-quot: ( obj -- ) -- ) > [ dup ] 2dip [ drop ] if ; inline I think you forgot "swap dip" before "[ drop ]". My version would be: : when-drop ( obj question-quot: ( obj -- ? ) true-quot: ( obj -- ) -- ) [ keep and ] dip when* ; inline -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2dcopy2___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] conditional combinator proposal
Hi Michele, On Fri, Sep 30, 2011 at 2:53 PM, Michele Pes 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 locals: : when-drop ( obj question-quot: ( obj -- ? ) true-quot: ( obj -- ) -- ) [ dup ] 2dip [ drop ] if ; inline Slava -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2dcopy2 ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] conditional combinator proposal
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 test-condition [ do something with obj ] [ drop ] if > > I think this would be better expressed this way: (always with obj on top > of stack) > [ do-test ] [ do-action-on-obj ] when-drop The words if* and when* already do this: do-test [ do-action-on-obj ] [ else ] if* do-test [ do-action-on-obj ] when* -Joe -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2dcopy2 ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
[Factor-talk] conditional combinator proposal
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 would be better expressed this way: (always with obj on top of stack) [ do-test ] [ do-action-on-obj ] when-drop To achieve this, I wrote this word: : when-drop ( obj question-quot: ( obj -- ? ) true-quot: ( obj -- ) -- ) -rot dupd call swapd [ call ] [ 2drop ] if ; inline But documentation claims that swapd and dupd are deprecated, and suggest to use lexical variables. So I rewrote this way: :: when-drop ( obj question-quot: ( ..obj -- ? ) true-quot: ( ..obj -- ) -- ) obj dup question-quot call [ true-quot call ] [ drop ] if ; inline Is this useless/redundant or do you think this can be interesting? thank you all, michele pes -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2dcopy2 ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk