add length.
This commit is contained in:
parent
270e272acc
commit
9a699da5c5
2
TODO
2
TODO
|
@ -15,7 +15,7 @@ v "string"
|
||||||
assq
|
assq
|
||||||
call-with-values
|
call-with-values
|
||||||
v char?
|
v char?
|
||||||
length
|
v length
|
||||||
v list
|
v list
|
||||||
list->vector
|
list->vector
|
||||||
make-vector
|
make-vector
|
||||||
|
|
12
mes.c
12
mes.c
|
@ -560,6 +560,18 @@ string_length (scm *x)
|
||||||
return make_number (strlen (x->name));
|
return make_number (strlen (x->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scm *
|
||||||
|
length (scm *x)
|
||||||
|
{
|
||||||
|
int n = 0;
|
||||||
|
while (x != &scm_nil)
|
||||||
|
{
|
||||||
|
n++;
|
||||||
|
x = cdr (x);
|
||||||
|
}
|
||||||
|
return make_number (n);
|
||||||
|
}
|
||||||
|
|
||||||
scm *
|
scm *
|
||||||
lookup (char *x, scm *a)
|
lookup (char *x, scm *a)
|
||||||
{
|
{
|
||||||
|
|
7
test.mes
7
test.mes
|
@ -182,4 +182,11 @@
|
||||||
(display (string #\a #\space #\s #\t #\r #\i #\n #\g #\newline))
|
(display (string #\a #\space #\s #\t #\r #\i #\n #\g #\newline))
|
||||||
(newline)
|
(newline)
|
||||||
|
|
||||||
|
(display "length of nil: ")
|
||||||
|
(display (length '()))
|
||||||
|
(newline)
|
||||||
|
(display "length of '(a b c): ")
|
||||||
|
(display (length '(a b c)))
|
||||||
|
(newline)
|
||||||
|
|
||||||
'()
|
'()
|
||||||
|
|
Loading…
Reference in a new issue