mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-08 05:27:33 +02:00
Added (flatten)
This commit is contained in:
parent
5f88a68525
commit
e044c362c2
1 changed files with 6 additions and 0 deletions
|
@ -40,6 +40,7 @@
|
||||||
gensym
|
gensym
|
||||||
delete
|
delete
|
||||||
delete-duplicates
|
delete-duplicates
|
||||||
|
flatten
|
||||||
list-index2
|
list-index2
|
||||||
list-insert-at!
|
list-insert-at!
|
||||||
list-prefix?
|
list-prefix?
|
||||||
|
@ -103,6 +104,11 @@
|
||||||
(if (eq? tail new-tail) lis (cons x new-tail)))))
|
(if (eq? tail new-tail) lis (cons x new-tail)))))
|
||||||
(recur lis))
|
(recur lis))
|
||||||
|
|
||||||
|
(define (flatten x)
|
||||||
|
(cond ((null? x) '())
|
||||||
|
((pair? x) (append (flatten (car x)) (flatten (cdr x))))
|
||||||
|
(else (list x))))
|
||||||
|
|
||||||
;; Insert obj at index k of list, increasing length of list by one.
|
;; Insert obj at index k of list, increasing length of list by one.
|
||||||
(define (list-insert-at! lis obj k)
|
(define (list-insert-at! lis obj k)
|
||||||
(cond
|
(cond
|
||||||
|
|
Loading…
Add table
Reference in a new issue