Chris Rathman writes:
 > In translating some more stuff into Oz, I have an accumlator that takes 
 > a function as a parameter.  The following works well enough:
 > 
 >   fun {Accumulate Initial Sequence Oper}
 >      case Sequence
 >         of nil then Initial
 >         [] H|T then {Oper H {Accumulate Initial T Oper}}
 >      end
 >   end
 > 
 >   {Browse {Accumulate 0 [1 2 3 4 5] (fun {$ A B} A + B end)}}
 > 
 > What I was wondering is how to specify the built-in operators as a 
 > function parameter, short of wrapping it into a lambda function like 
 > above?  Something like:
 > 
 >   {Browse {Accumulate 0 [1 2 3 4 5] op+}}
 > 
 > Where op+ is just supposed to be the binary plus operator as a function 
 > that takes two parameters.
 > 
 > Thanks,
 > Chris Rathman
 > 

Most (all?) operators have a procedural equivalent.  You can find them
in chapter 11 of the Base Environment documentation:

   http://www.mozart-oz.org/documentation/base/node14.html#chapter.infix

btw,  your Accumulate is List.foldR with the paremeters re-ordered: 

   fun {Accumulate Z L F}
     {List.foldR L F Z}
   end
 
cheers
k

_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to