aboutsummaryrefslogtreecommitdiff
path: root/p99/p14.neb
diff options
context:
space:
mode:
Diffstat (limited to 'p99/p14.neb')
-rw-r--r--p99/p14.neb15
1 files changed, 15 insertions, 0 deletions
diff --git a/p99/p14.neb b/p99/p14.neb
new file mode 100644
index 0000000..5af9fc0
--- /dev/null
+++ b/p99/p14.neb
@@ -0,0 +1,15 @@
+; P14: Duplicate the elements of a list.
+
+(def a (list "a" "b" "c" "c" "d"))
+
+(func dup (lst)
+ (reduce
+ (lambda (acc item)
+ (append
+ (append acc item)
+ item))
+ lst
+ (list)))
+
+(print (->string a))
+(print (->string (dup a)))