Re: [Factor-talk] Escapable each
Ouch, I correct the previous statement. > 2019/10/05 10:44、KUSUMOTO Norio のメール: > > Leave the code using while instead of nfind until the corresponding > code is included in the release build. *I* leave the code using while instead of nfind until the corresponding code is included in the release build. -- KUSUMOTO Norio ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Escapable each
Thank you for your quick response, John. Leave the code using while instead of nfind until the corresponding code is included in the release build. -- KUSUMOTO Norio > 2019/10/05 10:20、John Benediktsson のメール: > > This works in the non-optimizing compiler (for example, the Listener): > > 3 [ f ] times > > But not in the optimizing compiler. I pushed a quick fix that makes your > word work: > > https://github.com/factor/factor/commit/e17b9119293783728e193b29856d81ba5862c8eb > > ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Escapable each
This works in the non-optimizing compiler (for example, the Listener): 3 [ f ] times But not in the optimizing compiler. I pushed a quick fix that makes your word work: https://github.com/factor/factor/commit/e17b9119293783728e193b29856d81ba5862c8eb On Fri, Oct 4, 2019 at 5:29 PM KUSUMOTO Norio wrote: > I would like to use nfind as an escapable 2each, but I'm in trouble. > I simplified the problem as follows: > > In scratchpad, when I input: > > USE: sequences.generalizations > { 1 2 3 4 5 } { 5 4 3 2 1 } [ > ] 2 nfind > > get: > > --- Data stack: > 3 > 4 > 2 > > And I define nfind-test and use it: > > : nfind-test ( x y -- i/f elt1 elt2 ) [ > ] 2 nfind ; > { 1 2 3 4 5 } { 5 4 3 2 1 } nfind-test > > But I receive an error: > > The word nfind-test cannot be executed because it failed to compile > > The input quotation to “times” doesn't match its expected effect > Input Expected Got > [ f ] ( ... -- ... ) ( -- x ) > > > What am I wrong? > > > -- > KUSUMOTO Norio > > > > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk > ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Escapable each
I would like to use nfind as an escapable 2each, but I'm in trouble. I simplified the problem as follows: In scratchpad, when I input: USE: sequences.generalizations { 1 2 3 4 5 } { 5 4 3 2 1 } [ > ] 2 nfind get: --- Data stack: 3 4 2 And I define nfind-test and use it: : nfind-test ( x y -- i/f elt1 elt2 ) [ > ] 2 nfind ; { 1 2 3 4 5 } { 5 4 3 2 1 } nfind-test But I receive an error: The word nfind-test cannot be executed because it failed to compile The input quotation to “times” doesn't match its expected effect Input Expected Got [ f ] ( ... -- ... ) ( -- x ) What am I wrong? -- KUSUMOTO Norio ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Escapable each
> 2019/10/02 23:07、Alexander Ilin のメール: > > I like the LGBT reference, well done! : ) Oh, that's true. :-) -- KUSUMOTO Norio ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Escapable each
> 2019/10/02 22:23、John Benediktsson のメール: > > Any desire to make it available for others to use? Yes, of course! -- KUSUMOTO Norio ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Escapable each
I like the LGBT reference, well done! : ) 02.10.2019, 16:14, "KUSUMOTO Norio" : > 2019/09/23 18:03、Alexander Ilin のメール: >> Have you used the `backtrack` vocab for this? >> https://re-factor.blogspot.com/2015/06/send-more-money.html > > I ported a Prolog program to solve the same puzzle. > > USING: logica lists assocs sequences kernel math > locals formatting io ; > IN: logica.test.money > > LOGIC-PREDS: sumo sum1o digitsumo delo nonzeroo donaldo moneyo ; > LOGIC-VARS: S E N D M O R Y A L G B T > N1 N2 C C1 C2 D1 D2 L1 > Digits Digs Digs1 Digs2 Digs3 ; > > { sumo N1 N2 N } { > { sum1o N1 N2 N 0 0 L{ 0 1 2 3 4 5 6 7 8 9 } __ } > } si > > { sum1o L{ } L{ } L{ } 0 0 Digits Digits } semper > { sum1o [ D1 N1 cons ] [ D2 N2 cons ] [ D N cons ] C1 C Digs1 Digs } { > { sum1o N1 N2 N C1 C2 Digs1 Digs2 } > { digitsumo D1 D2 C2 D C Digs2 Digs } > } si > > { digitsumo D1 D2 C1 D C Digs1 Digs } { > { delo D1 Digs1 Digs2 } > { delo D2 Digs2 Digs3 } > { delo D Digs3 Digs } > [ [ [ D1 of ] [ D2 of ] [ C1 of ] tri + + ] S is ] > [ [ S of 10 mod ] D is ] > [ [ S of 10 / >integer ] C is ] > } si > > { delo A L L } { { nonvaro A } | } si > { delo A [ A L cons ] L } semper > { delo A [ B L cons ] [ B L1 cons ] } { delo A L L1 } si > > { moneyo L{ 0 S E N D } > L{ 0 M O R E } > L{ M O N E Y } > } semper > > { donaldo L{ D O N A L D } > L{ G E R A L D } > L{ R O B E R T } > } semper > > :: S-and-M-can't-be-zero ( seq -- seq' ) > seq [| hash | > 1 hash N1 of list>array nth 0 = not > 1 hash N2 of list>array nth 0 = not and > ] filter ; > > :: print-puzzle ( hash-array -- ) > hash-array > [| hash | > " " printf hash N1 of list>array [ "%d " printf ] each nl > "+ " printf hash N2 of list>array [ "%d " printf ] each nl > "" printf nl > " " printf hash N of list>array [ "%d " printf ] each nl nl > ] each ; > > IN: scratchpad [ { { moneyo N1 N2 N } { sumo N1 N2 N } } query > S-and-M-can't-be-zero > print-puzzle > ] time > 0 9 5 6 7 > + 0 1 0 8 5 > > 1 0 6 5 2 > > Running time: 0.320353468 seconds > > -- > KUSUMOTO Norio > > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk ---=--- Александр ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Escapable each
Logica seems pretty cool! Any desire to make it available for others to use? Best, John. > On Oct 2, 2019, at 9:15 AM, KUSUMOTO Norio wrote: > > 2019/09/23 18:03、Alexander Ilin のメール: >> >> >> Have you used the `backtrack` vocab for this? >> https://re-factor.blogspot.com/2015/06/send-more-money.html > > I ported a Prolog program to solve the same puzzle. > > > > USING: logica lists assocs sequences kernel math > locals formatting io ; > IN: logica.test.money > > LOGIC-PREDS: sumo sum1o digitsumo delo nonzeroo donaldo moneyo ; > LOGIC-VARS: S E N D M O R Y A L G B T >N1 N2 C C1 C2 D1 D2 L1 >Digits Digs Digs1 Digs2 Digs3 ; > > { sumo N1 N2 N } { >{ sum1o N1 N2 N 0 0 L{ 0 1 2 3 4 5 6 7 8 9 } __ } > } si > > { sum1o L{ } L{ } L{ } 0 0 Digits Digits } semper > { sum1o [ D1 N1 cons ] [ D2 N2 cons ] [ D N cons ] C1 C Digs1 Digs } { >{ sum1o N1 N2 N C1 C2 Digs1 Digs2 } >{ digitsumo D1 D2 C2 D C Digs2 Digs } > } si > > { digitsumo D1 D2 C1 D C Digs1 Digs } { >{ delo D1 Digs1 Digs2 } >{ delo D2 Digs2 Digs3 } >{ delo D Digs3 Digs } >[ [ [ D1 of ] [ D2 of ] [ C1 of ] tri + + ] S is ] >[ [ S of 10 mod ] D is ] >[ [ S of 10 / >integer ] C is ] > } si > > { delo A L L } { { nonvaro A } | } si > { delo A [ A L cons ] L } semper > { delo A [ B L cons ] [ B L1 cons ] } { delo A L L1 } si > > > { moneyo L{ 0 S E N D } > L{ 0 M O R E } > L{ M O N E Y } > } semper > > { donaldo L{ D O N A L D } > L{ G E R A L D } > L{ R O B E R T } > } semper > > :: S-and-M-can't-be-zero ( seq -- seq' ) >seq [| hash | > 1 hash N1 of list>array nth 0 = not > 1 hash N2 of list>array nth 0 = not and >] filter ; > > :: print-puzzle ( hash-array -- ) >hash-array >[| hash | > " " printf hash N1 of list>array [ "%d " printf ] each nl > "+ " printf hash N2 of list>array [ "%d " printf ] each nl > "" printf nl > " " printf hash N of list>array [ "%d " printf ] each nl nl >] each ; > > > > > IN: scratchpad [ { { moneyo N1 N2 N } { sumo N1 N2 N } } query > S-and-M-can't-be-zero > print-puzzle > ] time > 0 9 5 6 7 > + 0 1 0 8 5 > > 1 0 6 5 2 > > Running time: 0.320353468 seconds > > > -- > KUSUMOTO Norio > > > > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Escapable each
2019/09/23 18:03、Alexander Ilin のメール: > > > Have you used the `backtrack` vocab for this? > https://re-factor.blogspot.com/2015/06/send-more-money.html I ported a Prolog program to solve the same puzzle. USING: logica lists assocs sequences kernel math locals formatting io ; IN: logica.test.money LOGIC-PREDS: sumo sum1o digitsumo delo nonzeroo donaldo moneyo ; LOGIC-VARS: S E N D M O R Y A L G B T N1 N2 C C1 C2 D1 D2 L1 Digits Digs Digs1 Digs2 Digs3 ; { sumo N1 N2 N } { { sum1o N1 N2 N 0 0 L{ 0 1 2 3 4 5 6 7 8 9 } __ } } si { sum1o L{ } L{ } L{ } 0 0 Digits Digits } semper { sum1o [ D1 N1 cons ] [ D2 N2 cons ] [ D N cons ] C1 C Digs1 Digs } { { sum1o N1 N2 N C1 C2 Digs1 Digs2 } { digitsumo D1 D2 C2 D C Digs2 Digs } } si { digitsumo D1 D2 C1 D C Digs1 Digs } { { delo D1 Digs1 Digs2 } { delo D2 Digs2 Digs3 } { delo D Digs3 Digs } [ [ [ D1 of ] [ D2 of ] [ C1 of ] tri + + ] S is ] [ [ S of 10 mod ] D is ] [ [ S of 10 / >integer ] C is ] } si { delo A L L } { { nonvaro A } | } si { delo A [ A L cons ] L } semper { delo A [ B L cons ] [ B L1 cons ] } { delo A L L1 } si { moneyo L{ 0 S E N D } L{ 0 M O R E } L{ M O N E Y } } semper { donaldo L{ D O N A L D } L{ G E R A L D } L{ R O B E R T } } semper :: S-and-M-can't-be-zero ( seq -- seq' ) seq [| hash | 1 hash N1 of list>array nth 0 = not 1 hash N2 of list>array nth 0 = not and ] filter ; :: print-puzzle ( hash-array -- ) hash-array [| hash | " " printf hash N1 of list>array [ "%d " printf ] each nl "+ " printf hash N2 of list>array [ "%d " printf ] each nl "" printf nl " " printf hash N of list>array [ "%d " printf ] each nl nl ] each ; IN: scratchpad [ { { moneyo N1 N2 N } { sumo N1 N2 N } } query S-and-M-can't-be-zero print-puzzle ] time 0 9 5 6 7 + 0 1 0 8 5 1 0 6 5 2 Running time: 0.320353468 seconds -- KUSUMOTO Norio ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Escapable each
> 2019/09/23 18:03、Alexander Ilin のメール: > > Have you used the `backtrack` vocab for this? > https://re-factor.blogspot.com/2015/06/send-more-money.html No, I didn't. I didn't know it. This my liblary is a port from tiny_prolog and its descendants, ruby-prolog. https://github.com/preston/ruby-prolog The current number of lines, including a few built-in predicates, is 450. -- KUSUMOTO Norio ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Escapable each
Have you used the `backtrack` vocab for this? https://re-factor.blogspot.com/2015/06/send-more-money.html 23.09.2019, 10:43, "KUSUMOTO Norio" : >> 2019/09/22 20:21、Alexander Ilin のメール: >> >> I use `loop` or `while`, depending on the details. > > Hello. Thank you for your answer. > > I rewrote my program using `loop 'and `while'. The library I'm currently > building is an extended port from Ruby's one, and I used `with-return` > to mimic the code. > > The use of `with-return` in this code, which does a lot of repetition, > seems to have been a very bad choice. > The zebra puzzle is now running about 20 times faster than before. > > USING: factor-logica lists ; > IN: factor-logica.test.zebra > LOGIC-PREDS: houseso neighboro zebrao watero nexto lefto ; > LOGIC-VARS: Hs A B Ls X Y ; > SYMBOLS: red blue green white yellow ; > SYMBOLS: english swede dane norwegian german ; > SYMBOLS: dog cat birds horse zebra ; > SYMBOLS: tea coffee beer milk water ; > SYMBOLS: pall-mall dunhill blue-master prince blend ; > TUPLE: house color nationality drink smoke pet ; > > { houseso Hs X Y } { > { (=) Hs L{ ! #1 > T{ house f _ norwegian _ _ _ } ! #10 > T{ house f blue _ _ _ _ } ! #15 > T{ house f _ _ milk _ _ } _ _ } } ! #9 > { membero T{ house f red english _ _ _ } Hs } ! #2 > { membero T{ house f _ swede _ _ dog } Hs } ! #3 > { membero T{ house f _ dane tea _ _ } Hs } ! #4 > { lefto T{ house f green _ _ _ _ } T{ house f white _ _ _ _ } Hs } ! #5 > { membero T{ house f green _ coffee _ _ } Hs } ! #6 > { membero T{ house f _ _ _ pall-mall birds } Hs } ! #7 > { membero T{ house f yellow _ _ dunhill _ } Hs } ! #8 > { nexto T{ house f _ _ _ blend _ } T{ house f _ _ _ _ cat } Hs } ! #11 > { nexto T{ house f _ _ _ dunhill _ } T{ house f _ _ _ _ horse } Hs } ! #12 > { membero T{ house f _ _ beer blue-master _ } Hs } ! #13 > { membero T{ house f _ german _ prince _ } Hs } ! #14 > { nexto T{ house f _ _ water _ _ } T{ house f _ _ _ blend _ } Hs } ! #16 > { membero T{ house f _ X water _ _ } Hs } > { membero T{ house f _ Y _ _ zebra } Hs } > } si > > { nexto A B Ls } { > { appendo _ [ A B _ cons cons ] Ls } vel > { appendo _ [ B A _ cons cons ] Ls } > } si > > { lefto A B Ls } { appendo _ [ A B _ cons cons ] Ls } si > > IN: scratchpad { houseso Hs X Y } query . > { > H{ > { > Hs > L{ > T{ house > { color yellow } > { nationality norwegian } > { drink water } > { smoke dunhill } > { pet cat } > } > T{ house > { color blue } > { nationality dane } > { drink tea } > { smoke blend } > { pet horse } > } > T{ house > { color red } > { nationality english } > { drink milk } > { smoke pall-mall } > { pet birds } > } > T{ house > { color green } > { nationality german } > { drink coffee } > { smoke prince } > { pet zebra } > } > T{ house > { color white } > { nationality swede } > { drink beer } > { smoke blue-master } > { pet dog } > } > } > } > { X norwegian } > { Y german } > } > } > IN: scratchpad [ 1000 [ { houseso Hs X Y } query drop ] times ] time > > Running time: 20.393989632 seconds > > -- > KUSUMOTO Norio > > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk ---=--- Александр ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Escapable each
Wow, this looks very cool! : )) 23.09.2019, 10:43, "KUSUMOTO Norio" : >> 2019/09/22 20:21、Alexander Ilin のメール: >> >> I use `loop` or `while`, depending on the details. > > Hello. Thank you for your answer. > > I rewrote my program using `loop 'and `while'. The library I'm currently > building is an extended port from Ruby's one, and I used `with-return` > to mimic the code. > > The use of `with-return` in this code, which does a lot of repetition, > seems to have been a very bad choice. > The zebra puzzle is now running about 20 times faster than before. > > USING: factor-logica lists ; > IN: factor-logica.test.zebra > LOGIC-PREDS: houseso neighboro zebrao watero nexto lefto ; > LOGIC-VARS: Hs A B Ls X Y ; > SYMBOLS: red blue green white yellow ; > SYMBOLS: english swede dane norwegian german ; > SYMBOLS: dog cat birds horse zebra ; > SYMBOLS: tea coffee beer milk water ; > SYMBOLS: pall-mall dunhill blue-master prince blend ; > TUPLE: house color nationality drink smoke pet ; > > { houseso Hs X Y } { > { (=) Hs L{ ! #1 > T{ house f _ norwegian _ _ _ } ! #10 > T{ house f blue _ _ _ _ } ! #15 > T{ house f _ _ milk _ _ } _ _ } } ! #9 > { membero T{ house f red english _ _ _ } Hs } ! #2 > { membero T{ house f _ swede _ _ dog } Hs } ! #3 > { membero T{ house f _ dane tea _ _ } Hs } ! #4 > { lefto T{ house f green _ _ _ _ } T{ house f white _ _ _ _ } Hs } ! #5 > { membero T{ house f green _ coffee _ _ } Hs } ! #6 > { membero T{ house f _ _ _ pall-mall birds } Hs } ! #7 > { membero T{ house f yellow _ _ dunhill _ } Hs } ! #8 > { nexto T{ house f _ _ _ blend _ } T{ house f _ _ _ _ cat } Hs } ! #11 > { nexto T{ house f _ _ _ dunhill _ } T{ house f _ _ _ _ horse } Hs } ! #12 > { membero T{ house f _ _ beer blue-master _ } Hs } ! #13 > { membero T{ house f _ german _ prince _ } Hs } ! #14 > { nexto T{ house f _ _ water _ _ } T{ house f _ _ _ blend _ } Hs } ! #16 > { membero T{ house f _ X water _ _ } Hs } > { membero T{ house f _ Y _ _ zebra } Hs } > } si > > { nexto A B Ls } { > { appendo _ [ A B _ cons cons ] Ls } vel > { appendo _ [ B A _ cons cons ] Ls } > } si > > { lefto A B Ls } { appendo _ [ A B _ cons cons ] Ls } si > > IN: scratchpad { houseso Hs X Y } query . > { > H{ > { > Hs > L{ > T{ house > { color yellow } > { nationality norwegian } > { drink water } > { smoke dunhill } > { pet cat } > } > T{ house > { color blue } > { nationality dane } > { drink tea } > { smoke blend } > { pet horse } > } > T{ house > { color red } > { nationality english } > { drink milk } > { smoke pall-mall } > { pet birds } > } > T{ house > { color green } > { nationality german } > { drink coffee } > { smoke prince } > { pet zebra } > } > T{ house > { color white } > { nationality swede } > { drink beer } > { smoke blue-master } > { pet dog } > } > } > } > { X norwegian } > { Y german } > } > } > IN: scratchpad [ 1000 [ { houseso Hs X Y } query drop ] times ] time > > Running time: 20.393989632 seconds > > -- > KUSUMOTO Norio > > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk ---=--- Александр ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Escapable each
> 2019/09/22 20:21、Alexander Ilin のメール: > > I use `loop` or `while`, depending on the details. Hello. Thank you for your answer. I rewrote my program using `loop 'and `while'. The library I'm currently building is an extended port from Ruby's one, and I used `with-return` to mimic the code. The use of `with-return` in this code, which does a lot of repetition, seems to have been a very bad choice. The zebra puzzle is now running about 20 times faster than before. USING: factor-logica lists ; IN: factor-logica.test.zebra LOGIC-PREDS: houseso neighboro zebrao watero nexto lefto ; LOGIC-VARS: Hs A B Ls X Y ; SYMBOLS: red blue green white yellow ; SYMBOLS: english swede dane norwegian german ; SYMBOLS: dog cat birds horse zebra ; SYMBOLS: tea coffee beer milk water ; SYMBOLS: pall-mall dunhill blue-master prince blend ; TUPLE: house color nationality drink smoke pet ; { houseso Hs X Y } { { (=) Hs L{! #1 T{ house f _ norwegian _ _ _ } ! #10 T{ house f blue _ _ _ _ }! #15 T{ house f _ _ milk _ _ } _ _ } }! #9 { membero T{ house f red english _ _ _ } Hs } ! #2 { membero T{ house f _ swede _ _ dog } Hs }! #3 { membero T{ house f _ dane tea _ _ } Hs } ! #4 { lefto T{ house f green _ _ _ _ } T{ house f white _ _ _ _ } Hs } ! #5 { membero T{ house f green _ coffee _ _ } Hs } ! #6 { membero T{ house f _ _ _ pall-mall birds } Hs } ! #7 { membero T{ house f yellow _ _ dunhill _ } Hs } ! #8 { nexto T{ house f _ _ _ blend _ } T{ house f _ _ _ _ cat } Hs } ! #11 { nexto T{ house f _ _ _ dunhill _ } T{ house f _ _ _ _ horse } Hs } ! #12 { membero T{ house f _ _ beer blue-master _ } Hs } ! #13 { membero T{ house f _ german _ prince _ } Hs }! #14 { nexto T{ house f _ _ water _ _ } T{ house f _ _ _ blend _ } Hs } ! #16 { membero T{ house f _ X water _ _ } Hs } { membero T{ house f _ Y _ _ zebra } Hs } } si { nexto A B Ls } { { appendo _ [ A B _ cons cons ] Ls } vel { appendo _ [ B A _ cons cons ] Ls } } si { lefto A B Ls } { appendo _ [ A B _ cons cons ] Ls } si IN: scratchpad { houseso Hs X Y } query . { H{ { Hs L{ T{ house { color yellow } { nationality norwegian } { drink water } { smoke dunhill } { pet cat } } T{ house { color blue } { nationality dane } { drink tea } { smoke blend } { pet horse } } T{ house { color red } { nationality english } { drink milk } { smoke pall-mall } { pet birds } } T{ house { color green } { nationality german } { drink coffee } { smoke prince } { pet zebra } } T{ house { color white } { nationality swede } { drink beer } { smoke blue-master } { pet dog } } } } { X norwegian } { Y german } } } IN: scratchpad [ 1000 [ { houseso Hs X Y } query drop ] times ] time Running time: 20.393989632 seconds -- KUSUMOTO Norio ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Escapable each
Honestly, I remember asking the same question a long time ago. Haha. On Sun, Sep 22, 2019 at 8:17 PM KUSUMOTO Norio wrote: > > 2019/09/22 22:41、Doug Coleman のメール: > > > > You can use 'find' itself as an 'each'. Do whatever you each would do > before checking the stop condition and return true when your stop condition > is met. Then drop what you found if you don't need it. > > > That's true! I was bound by the impression I got from Word's name. > > > > > -- > KUSUMOTO Norio > > > > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk > ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Escapable each
> 2019/09/22 22:41、Doug Coleman のメール: > > You can use 'find' itself as an 'each'. Do whatever you each would do before > checking the stop condition and return true when your stop condition is met. > Then drop what you found if you don't need it. That's true! I was bound by the impression I got from Word's name. -- KUSUMOTO Norio ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Escapable each
You can use 'find' itself as an 'each'. Do whatever you each would do before checking the stop condition and return true when your stop condition is met. Then drop what you found if you don't need it. On Sun, Sep 22, 2019, 6:21 AM Alexander Ilin wrote: > I use `loop` or `while`, depending on the details. > > 22.09.2019, 13:05, "KUSUMOTO Norio" : > > Hello all, > > > > 'each 'and' 2each 'are very useful for writing iterative processes, but > sometimes > > I want to get out of a process before repeating it to the end under > certain conditions. > > > > I think it would be possible to write such a combinator because 'find' > stops iterating > > when it finds something that satisfies the condition, but I don't know > how to write > > 'each' that can escape. > > > > What code do you write for such a process? > > I use 'with-return' to handle such situations. But I suspect it's > costing time. > > ---=--- > Александр > > > > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk > ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Escapable each
I use `loop` or `while`, depending on the details. 22.09.2019, 13:05, "KUSUMOTO Norio" : > Hello all, > > 'each 'and' 2each 'are very useful for writing iterative processes, but > sometimes > I want to get out of a process before repeating it to the end under certain > conditions. > > I think it would be possible to write such a combinator because 'find' stops > iterating > when it finds something that satisfies the condition, but I don't know how to > write > 'each' that can escape. > > What code do you write for such a process? > I use 'with-return' to handle such situations. But I suspect it's costing > time. ---=--- Александр ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk