Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Functional programming in REBOL

From: g:santilli:tiscalinet:it at: 8-Aug-2001 23:40

Hello Larry! On 08-Ago-01, you wrote: LP>> pa2: func [f x] [ LP>> use [ff xx] [ LP>> xx: :x LP>> ff: :f LP>> func [y] [ff xx y] LP>> ] LP>> ] LP> Yes, I have a set of higher-order funcs written in exactly LP> that fashion. But I don't like it. Renaming all the variables LP> in the code block is ugly, and it seemed to me the approach LP> would be cumbersome (and perhaps diffcult) to generalize for LP> creating the generic cfunc. I think changing only the spec LP> blocks as in cfunc or Ladislav's e-func is preferable. Yes, of course you can also write: pa2: func [f x /local w] [ w: use [f x] ['f] set bind [f x] w reduce [:f :x] func [y] bind [f x y] w ] Of course all this can be generalized. LP> I really liked that one. Unfortunately, it doesn't pass the LP> mystery test as shown in the console session below where I LP> have renamed your version to pa4. [...] LP>>> type? mystery4 :+ LP> ** Script Error: y expected value1 argument of type: number LP> pair char mone y date time tuple So that would need to be changed to: pa4: func [f x] [ func [y] reduce [:f :x to-get-word 'y] ] or (will have problems with blocks): pa4: func [f x] [ func [y] compose [(:f) (:x) :y] ] or even: pa4: func [f x] [ func [y] reduce [get 'f get 'x 'get to-lit-word 'y] ] or any other variant. Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/