Paste: clay values lib

Author: j
Mode: text
Date: Sun, 1 Aug 2010 16:41:29
Plain Text |
procedure eachValue;
overload eachValue(fn, x, ...xs) { fn(x); eachValue(fn, ...xs); }
overload eachValue(fn) { }

procedure mapValues;
overload mapValues(fn, x, ...xs) = ...fn(x), mapValues(fn, ...xs);
overload mapValues(fn) = ;

procedure foldValues;
overload foldValues(fn, x, ...xs) = fn(x, foldValues(fn, ...xs));
overload foldValues(fn, x) = x;

procedure weaveValues;
overload weaveValues(between, x, ...xs) = x, between, ...weaveValues(between, ...xs);
overload weaveValues(between, x, y) = x, between, y;
overload weaveValues(between, x) = x;

Annotation: forwarding

Author: j
Mode: text
Date: Sun, 1 Aug 2010 17:09:24
Plain Text |
procedure eachValue;
overload eachValue(fn, forward x, forward ...xs) { fn(x); eachValue(fn, ...xs); }
overload eachValue(fn) { }

procedure mapValues;
overload mapValues(fn, forward x, forward ...xs)
    = forward ...fn(x), ...mapValues(fn, ...xs);
overload mapValues(fn) = ;

procedure foldValues;
overload foldValues(fn, forward x, forward ...xs)
    = fn(x, foldValues(fn, ...xs));
overload foldValues(fn, forward x) = forward x;

procedure weaveValues;
overload weaveValues(forward between, forward x, forward ...xs)
    = forward x, between, ...weaveValues(between, ...xs);
overload weaveValues(forward between, forward x, forward y)
    = forward x, between, y;
overload weaveValues(forward between, forward x) = forward x;

New Annotation

Summary:
Author:
Mode:
Body: