user-defined operators

Eric Newhuis <>
Thu Mar 25 19:15:14 CET 2004


> I tend to '-import' any well-known functions that I use from 'lists'.

Yes good point.  foreach is a simple one.  The others like foldl always 
throw me.  I am always going back to the man pages.  K's foldl operator 
is just a single forward slash ("/").  It is pronounced "over".

F / Vector is read as "F over Vector".

Example:  Accumulate sum over a vector of integers:

K:
+/1 2 3 4 5

Erlang:
lists:foldl (fun (X, A) -> X + A end, 0, [1, 2, 3, 4]).

Would be nice to just say this in Erlang:

0 + over [1, 2, 3, 4].




More information about the erlang-questions mailing list