Chris Rathman writes: > More of curiosity question at the moment as I attempt to translate SICP, > but does Oz have he ability to compose functions in the manner of > composition operator? Taking a simple ML example: > > val car = hd > val cdr = tl > val cadr = car o cdr > > And extrapolating that idea to my pseudo Oz code, I'd have something > along the lines of: > > fun {CAR L} L.1 end > fun {CDR L} L.2 end > fun {CADR L} CAR o CDR end > > To relate the question to CTM, the book gives a Haskell example in > section 4.7.2 that has an expression within the sqrt function: > > dropWhile (not . gooEnough) > > where the dot operator in Haskell does effectively the same that the o > operator does above. >
Hi Chris, There is no compose operator in Mozart/Oz and, unlike Haskell, you can't add your own new operators. However, compose is just an ordinary higher orderfunction, so: fun {Compose F G} fun {$ X} {F {G X}} end end fun {CAR L} L.1 end fun {CDR L} L.2 end fun {CADR L} {{Compose CAR CDR} L} end and {List.dropWhile [1 2 3] {Compose Not IsEven}} It is certainly a bit noisier than ML or Haskell, but the effect is the same. cheers k _________________________________________________________________________________ mozart-users mailing list mozart-users@ps.uni-sb.de http://www.mozart-oz.org/mailman/listinfo/mozart-users