changeset 27:abd8ceef0dd8

Added flatten function
author William Morgan <billjunk@mrgn.org>
date Fri, 25 Jul 2014 23:36:17 -0700
parents 4f7a421e77c6
children 75c97fb80602
files code/mike00.lm
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/code/mike00.lm	Fri Jul 25 23:19:29 2014 -0700
+++ b/code/mike00.lm	Fri Jul 25 23:36:17 2014 -0700
@@ -55,6 +55,14 @@
 		}
 		reverse: new
 	}
+
+	flatten <- :lst {
+		fold: lst [] with: :acc el {
+			fold: el acc with: :iacc iel {
+				iel | iacc
+			}
+		}
+	}
 	
 	makeTree:size <- :lst :size {
 		ret <- 0
@@ -191,6 +199,7 @@
 		print: (fold: lst 0 with: :acc el { acc + el })
 		print: (filter: lst :el { el > 4 })
 		print: (tree: tree update: 8 with: :el { el + 29 })
+		print: (flatten: [lst lst lst])
 	}
 	
-}
\ No newline at end of file
+}