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

[REBOL] Re: syntax across languages

From: lmecir:mbox:vol:cz at: 15-Nov-2003 19:14

Anton Rolls wrote:
>I am not completely sure what function composition means. >Pixel said: "function composition is a function taking 2 >functions and returning a new one." > >Looking at some Haskell posts I see it kind of >glues two functions together, passing the result >from the first function into the second one. >There are (resolvable) problems when the number of >arguments are not the same, but, anyway... >Doesn't this just mean that this is function >composition: > > add: func [a b][a + b] > mul3: func [a][a * 3] > add-mul3: func [a b][mul3 add a b] > >? >Or it doesn't count because the "composition" >is specified in the body block, whereas Haskell >does it by referring only to the function names. >
It "doesn't count", an answer in Rebol (needs some polishing): composition: func [ f [any-function!] g [any-function!] ] [ use [f' g' body] copy/deep [ f': :f g': :g body: [f' g'] foreach arg first :g [ insert tail body reduce ['get/any to lit-word! arg] ] func load mold third :g body ] ] Usage: add-mul3: composition :mul3 :add -Ladislav