Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
65 lines (49 sloc) 952 Bytes
export list
inline C <<end
datum
cons(datum x, datum y)
{
return make_record(2, pair_mtab, x, y);
}
inline pair
datum2pair(datum d)
{
if (!pairp(d)) die1("not a pair", d);
return (pair) d;
}
int
pairp(datum x)
{
return (!(((size_t) x) & 1)) &&
(datum_size(x) == 2) &&
(((datum) x[-1]) == pair_mtab);
}
end
def pair: sobj:
inline C (set-cdr! x) <<end
rcv[1] = (size_t) n_x;
return ok_sym;
end
inline C (car.) <<end
return car(rcv);
end
inline C (cdr.) <<end
return cdr(rcv);
end
(length.) 1 + self.cdr.length
(filter f):
def rest ((self.cdr).filter f)
? (f (self.car)):
cons (self.car) rest
. rest
(run f):
f (self.car)
(self.cdr) f
. 'ok
(== p):
? ((self.car) == (p.car)):
? ((self.cdr) == (p.cdr)) true false
. false
(assq name):
? (is? (self.car.car) name) (self.car) (self.cdr.assq name)
def (list . args): args