aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-01-30 12:04:51 +0100
committerThomas White <taw@physics.org>2021-01-30 12:10:32 +0100
commitc0d903c2e16eccc444ea95187a02f3e0dfe639ae (patch)
tree1ac6b8dc7b8216e0af02da13fb9ba86242fd6eed
parent864c928d6ca8f356c2813f89659d3e3549c170d6 (diff)
flatten-sublists: Preserve order
-rw-r--r--guile/starlet/base.scm10
1 files changed, 7 insertions, 3 deletions
diff --git a/guile/starlet/base.scm b/guile/starlet/base.scm
index f64ea51..780ff44 100644
--- a/guile/starlet/base.scm
+++ b/guile/starlet/base.scm
@@ -566,10 +566,14 @@
(define (flatten-sublists l)
+
+ (define (listify a)
+ (if (list? a)
+ a
+ (list a)))
+
(fold (lambda (a prev)
- (if (list? a)
- (append a prev)
- (cons a prev)))
+ (append prev (listify a)))
'() l))