changeset 188:7e313849ab41

Add join method to lists
author Mike Pavone <pavone@retrodev.com>
date Mon, 26 Aug 2013 18:21:57 -0700
parents 810edf474f86
children a45e535f7742
files modules/list.tp
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/modules/list.tp	Mon Aug 26 17:46:47 2013 -0700
+++ b/modules/list.tp	Mon Aug 26 18:21:57 2013 -0700
@@ -9,6 +9,7 @@
 			list node: val withTail: self
 		}
 		. <- :right { right }
+		join <- { "" }
 		string <- { "[]" }
 		print <- { print: string }
 	}
@@ -51,6 +52,11 @@
 						node: val withTail: tail
 					}
 				}
+				join <- :sep {
+					_tail fold: (string: _val) with: :acc el {
+						acc . sep . el
+					}
+				}
 				string <- {
 					(fold: "[\n" with: :acc el {
 						acc . "	" . (string: el) . "\n"