changeset 215:f3d5068cbd43

Add contains? method to list
author Michael Pavone <pavone@retrodev.com>
date Sat, 21 Dec 2013 12:06:10 -0800
parents e01137a97654
children 2dac67e9d18b
files modules/list.tp
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/modules/list.tp	Fri Dec 06 19:19:54 2013 -0800
+++ b/modules/list.tp	Sat Dec 21 12:06:10 2013 -0800
@@ -11,6 +11,7 @@
 		. <- :right { right }
 		reverse <- { self }
 		join <- { "" }
+		contains? <- :val { false }
 		string <- { "[]" }
 		print <- { print: string }
 	}
@@ -63,6 +64,13 @@
 						acc . sep . el
 					}
 				}
+				contains? <- :val {
+					if: _val = val {
+						true
+					} else: {
+						_tail contains?: val
+					}
+				}
 				string <- {
 					(fold: "[\n" with: :acc el {
 						acc . "	" . (string: el) . "\n"