* Added list-tail.
This commit is contained in:
parent
0c62d5bee8
commit
e76047cb47
BIN
src/ikarus.boot
BIN
src/ikarus.boot
Binary file not shown.
|
@ -5,7 +5,7 @@
|
||||||
(import
|
(import
|
||||||
(ikarus system $stack)
|
(ikarus system $stack)
|
||||||
(except (ikarus) call/cf call/cc call-with-current-continuation
|
(except (ikarus) call/cf call/cc call-with-current-continuation
|
||||||
dynamic-wind exit))
|
dynamic-wind exit list-tail))
|
||||||
|
|
||||||
(define primitive-call/cf
|
(define primitive-call/cf
|
||||||
(lambda (f)
|
(lambda (f)
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
(library (ikarus lists)
|
(library (ikarus lists)
|
||||||
(export $memq list? list list* make-list append length list-ref reverse
|
(export $memq list? list list* make-list append length list-ref reverse
|
||||||
last-pair memq memv member assq assv assoc
|
last-pair memq memv member assq assv assoc
|
||||||
map for-each andmap ormap)
|
map for-each andmap ormap list-tail)
|
||||||
(import
|
(import
|
||||||
(ikarus system $fx)
|
(ikarus system $fx)
|
||||||
(ikarus system $pairs)
|
(ikarus system $pairs)
|
||||||
(except (ikarus) list? list list* make-list append reverse
|
(except (ikarus) list? list list* make-list append reverse
|
||||||
last-pair length list-ref memq memv member assq assv
|
last-pair length list-ref memq memv member assq assv
|
||||||
assoc map for-each andmap ormap))
|
assoc map for-each andmap ormap list-tail))
|
||||||
|
|
||||||
(define $memq
|
(define $memq
|
||||||
(lambda (x ls)
|
(lambda (x ls)
|
||||||
|
@ -96,6 +96,22 @@
|
||||||
(error 'list-ref "~s is not a valid index" index))
|
(error 'list-ref "~s is not a valid index" index))
|
||||||
(f list index)))
|
(f list index)))
|
||||||
|
|
||||||
|
|
||||||
|
(define list-tail
|
||||||
|
(lambda (list index)
|
||||||
|
(define f
|
||||||
|
(lambda (ls i)
|
||||||
|
(cond
|
||||||
|
[($fxzero? i) ls]
|
||||||
|
[(pair? ls)
|
||||||
|
(f ($cdr ls) ($fxsub1 i))]
|
||||||
|
[(null? ls)
|
||||||
|
(error 'list-tail "index ~s is out of range for ~s" index list)]
|
||||||
|
[else (error 'list-tail "~s is not a list" list)])))
|
||||||
|
(unless (and (fixnum? index) ($fx>= index 0))
|
||||||
|
(error 'list-tail "~s is not a valid index" index))
|
||||||
|
(f list index)))
|
||||||
|
|
||||||
(module (append)
|
(module (append)
|
||||||
(define reverse
|
(define reverse
|
||||||
(lambda (h t ls ac)
|
(lambda (h t ls ac)
|
||||||
|
|
|
@ -273,6 +273,7 @@
|
||||||
[cddddr i r]
|
[cddddr i r]
|
||||||
[list i r]
|
[list i r]
|
||||||
[list-ref i r]
|
[list-ref i r]
|
||||||
|
[list-tail i r]
|
||||||
[make-list i r]
|
[make-list i r]
|
||||||
[list* i]
|
[list* i]
|
||||||
[list? i r]
|
[list? i r]
|
||||||
|
|
Loading…
Reference in New Issue