Name: Anonymous 2011-01-09 22:35
There are too many ways to do it.
The completely backwards way:
On the other hand, closures are much nicer now (JavaScript needs this):
Note about .reduce: it only supports binary functions.
A note on operators:
Hyperops, eg:
These are permitted to auto-parallelize (implementation dependent.)
Lazy meta-ops, eg:
These support lazy evaluation. The result is generated as needed.
Reduction meta-ops, eg:
Triangular reduction: [code][\+] 1,2,3,4,5 # result is (1,3,6,10,15)[code]
These are basically .reduce(*[b][i]op[/i][/b]*) with the binary operator provided.
The completely backwards way:
> sub foo(&f) { f() }
{ "hi".say }.&foo();
hiOn the other hand, closures are much nicer now (JavaScript needs this):
> say (1,2,3,4,5).reduce: { $^a + $^b };
15Note about .reduce: it only supports binary functions.
A note on operators:
Hyperops, eg:
(1,2,3,4) «+» (5,6,7,8)These are permitted to auto-parallelize (implementation dependent.)
Lazy meta-ops, eg:
1,2,3,4 Z+ 5,6,7,8These support lazy evaluation. The result is generated as needed.
Reduction meta-ops, eg:
[+] 1,2,3,4,5Triangular reduction: [code][\+] 1,2,3,4,5 # result is (1,3,6,10,15)[code]
These are basically .reduce(*[b][i]op[/i][/b]*) with the binary operator provided.