[Nickle]Array comprehension syntax
Keith Packard
nickle@nickle.org
Mon, 05 Aug 2002 19:11:36 -0700
Around 23 o'clock on Aug 4, Bart Massey wrote:
> the comprehension should just take formal names and an expression, like the
> Smalltalk block construct.
How about two forms:
a) { = (i, j) i * j }
b) { = (i, j) { return i * j; } }
These are trivial to distinguish, although my compose example does
take advantage of the ability to use an arbitrary function valued
expression as a comprehension which I thought was a pretty nifty trick.
Here's what compose would look like with form a):
poly (poly...) compose (poly f, poly g) {
return poly func (poly args...) {
return f (g ((poly[func_args(g)]) { = (i) args[i] } ...),
(poly[func_args(f)-1]) { = (i) args[func_args(g)+i] }...);
};
}
It's getting shorter and shorter...
Keith Packard XFree86 Core Team HP Cambridge Research Lab