Re: [stack] recursive combinators in other languages
Stevan Apter <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
----- Original Message ----- From: "rahul" <[email protected]> To: <[email protected]> Sent: Sunday, March 16, 2008 3:15 AM Subject: Re: [stack] recursive combinators in other languages > Christopher Diggins: > >>> Are there other languages that use the same form? >> >> Well this isn't so much a language property, as a feature of the >> standard library. Some languages make it easy to define combinators of >> that form, but they aren't idiomatic (Haskell for example). > > Well, it is certainly possible to achieve the same in any language that > support lambdas, but none are as elegent as in Joy (AFAIK). I was > surprised by the very consise definition and pervasive use of these > in Nial. (Is it done the same way in K and J ?) at one point i thought it might be useful to have a set of joy-style recursive combinators in k. we have six iterators which cover most of the iteration cases encountered (e.g. */ for product, -': for pairwise difference, &c.), so the usefulness of a parallel set of "recursors" depends on how often nothing but recursion will do. in many instances, an algorithm you'd normally define recursively has an iterative solution which can then be expressed with iterators, e.g.: fibonacci:(|+\)\1 1 but it isn't difficult to define the recursors: rec:{[c;h;f;g;x]$[c x;h x;f[x;rec[c;h;f;g]g x]]} fac:rec[0=;{1};*/;-1+] fac 5 120 rec takes four arguments, each of which is a function, and a fifth argument, which is the data over which to recur. > > see also Q5 in > http://www.latrobe.edu.au/philosophy/phimvt/joy/faq1.html > > > > > ... >>> The definition of factorial in Nial is given by >>> >>> factorial is recur [ 0 =, 1 first, pass, product, -1 +] > > ------------------------------------ > > Yahoo! Groups Links > > > ------------------------------------ Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/concatenative/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/concatenative/join (Yahoo! ID required) <*> To change settings via email: mailto:[email protected] mailto:[email protected] <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/