Functions on type t_binding

t_bool operator==(t_binding b1, t_binding b2)

Returns

t_bool operator!=(t_binding b1, t_binding b2) = operator!(operator==(b1, b2))

t_binding _bind1(t_text n, t_value v)

If

t_binding _head(t_binding b)

Returns a binding with one (name, value) pair equal to the first element of

t_binding _tail(t_binding b)

Returns the binding consisting of all elements of

t_int _length(t_binding b)

Returns the number of (name, value) pairs in

t_binding _elem(t_binding b, t_int i)

Returns a binding consisting solely of the

t_text _n(t_binding b)

If

t_value _v(t_binding b)

If

t_bool _defined(t_binding b, t_text name)

If

t_value _lookup(t_binding b, t_text name)

If

t_binding _append(t_binding b1, t_binding b2)

Returns a binding formed by appending

t_binding operator+(t_binding b1, t_binding b2) = { val r = emptybinding; for (; !(b1 == emptybinding); b1 = _tail(b1)) { val n = _n(_head(b1)); val v; if (_defined(b2, n) == true) v = _lookup(b2, n); else v = _v(_head(b1)); r = _append(r, _bind1(n, v)); } for (; !(b2 == emptybinding); b2 = _tail(b2)) { if (_defined(b1, _n(_head(b2)) == false) r = _append(r, _head(b2)); } return r; }

Returns a binding formed by appending

t_binding operator++(t_binding b1, t_binding b2) = { val r = emptybinding; for (; !(b1 == emptybinding); b1 = _tail(b1)) { val n = _n(_head(b1)); val v; if (_defined(b2, n) == true) { val v2 = _lookup(b2, n); if (_is_binding(v2) == true) { v = _v(_head(b1); if (_is_binding(v) == true) v = operator++(v, v2); else v = v2; } else v = v2; } else v = _v(_head(b1)); r = _append(r, _bind1(n, v)); } for (; !(b2 == emptybinding); b2 = _tail(b2)) { if (_defined(r, _n(_head(b2)) == false) r = _append(r, _head(b2)); } return r; }

Similar to operator+, but performs the operation recursively for each name

t_binding operator-(t_binding b1, t_binding b2) = { val r = emptybinding; for (; !(b1 = emptybinding); b1 = _tail(b1)) { val n = _n(_head(b1)); if (_defined(b2, n) == false) r = _append(r, _head(b1)); } return r; }

Returns a binding formed by removing from

t_binding _sub(t_binding b, t_int start = 0, t_int len = _length(b)) { int w = _length(b); int i = _min(_max(start, 0)), w); int j = _min(i + _max(len, 0), w); // 0 <= i <= j <= _length(b); extract [i..j) t_binding r = emptybinding; for (; i < j; i++) r = _append(r, _elem(b, i)); return r; }

Returns the sub-binding of

t_binding _map(t_closure f, t_binding b) = { t_binding res = emptybinding; for (; !(b == emptybinding); b = _tail(l)) { // apply the closure "f" t_binding b1 = f(_n(_head(b)), _v(_head(b))); res = _append(res, b1); } return res; }

Returns the binding that results from applying the closure

t_binding _par_map(t_closure f, t_binding b)

Formally equivalent to