Add possibly useful utility procedures
This commit is contained in:
parent
6529021476
commit
3632855fe5
|
@ -31,5 +31,23 @@
|
|||
(if (null? l) true
|
||||
(if (f (car l))
|
||||
true
|
||||
false)))))
|
||||
false)))
|
||||
|
||||
(define (length l)
|
||||
(if (null? l)
|
||||
0
|
||||
(+ 1 (length (cdr l)))))
|
||||
|
||||
(define (list-ref list k)
|
||||
(if (= k 0)
|
||||
(car list)
|
||||
(list-ref (cdr list) (- k 1))))
|
||||
|
||||
;; Remove the kth element from list
|
||||
(define (remove list k)
|
||||
(if (= k 0)
|
||||
(cdr list)
|
||||
(cons (car list)
|
||||
(remove (cdr list) (- k 1)))))
|
||||
))
|
||||
|
||||
|
|
Loading…
Reference in New Issue