X-Git-Url: https://jxself.org/git/?p=mes.git;a=blobdiff_plain;f=lib.c;h=b252ef1a014e8cce6b0ccdda49ad874492e93f11;hp=f1cb8e948d52a0e8ff7730cb17d973919e7887ff;hb=3b4e9f36c87ca1d216619bfbbfc2a3d48478f294;hpb=d209a1812101264a2186700e35dff1860b41598b diff --git a/lib.c b/lib.c index f1cb8e94..b252ef1a 100644 --- a/lib.c +++ b/lib.c @@ -56,6 +56,16 @@ list (scm *x) ///((args . n)) return x; } +scm * +list_ref (scm *x, scm *k) +{ + assert (x->type == PAIR); + assert (k->type == NUMBER); + int n = k->value; + while (n-- && x->cdr != &scm_nil) x = x->cdr; + return x != &scm_nil ? x->car : &scm_undefined; +} + scm * vector_to_list (scm *v) {