|
From: | David Nalesnik |
Subject: | Re: scheme-question about unnesting list |
Date: | Fri, 10 Apr 2015 09:44:56 -0500 |
Hi,
consider the following list:
(define ls
(list
"a"
(list
(cons 'x "xx")
(cons 'y "yy")
(list 1 2 3))
(cons 'z "zz")))
I want to unnest it one level.
It can be done with the procedure 'unnest-list-one-lvl', which I
defined for that purpose:
(define (unnest-list-one-lvl l)
(append-map
(lambda (e)
(if (list? e)
e
(list e)))
l))
(unnest-list-one-lvl ls)
-> ("a" (x . "xx") (y . "yy") (1 2 3) (z . "zz"))
Question:
Is there a better, easier way?
[Prev in Thread] | Current Thread | [Next in Thread] |