projects
/
mes.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Simplify toplevel read.
[mes.git]
/
lib.c
diff --git
a/lib.c
b/lib.c
index 4d7a617645dd42279652207ada2624ca9fd23447..b252ef1a014e8cce6b0ccdda49ad874492e93f11 100644
(file)
--- a/
lib.c
+++ b/
lib.c
@@
-56,12
+56,25
@@
list (scm *x) ///((args . n))
return x;
}
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)
{
scm *x = &scm_nil;
scm *
vector_to_list (scm *v)
{
scm *x = &scm_nil;
- for (int i = 0; i < v->length; i++)
- x = append2 (x, cons (v->vector[i], &scm_nil));
+ for (int i = 0; i < v->length; i++) {
+ scm *e = &v->vector[i];
+ if (e->type == REF) e = e->ref;
+ x = append2 (x, cons (e, &scm_nil));
+ }
return x;
}
return x;
}