diff pattern.rhope @ 156:ed70399a07aa

Add Substring method to string and improve performance of Partition
author Mike Pavone <pavone@retrodev.com>
date Thu, 23 Dec 2010 02:00:27 +0000
parents d86df83402f3
children f97a7d499182
line wrap: on
line diff
--- a/pattern.rhope	Tue Dec 21 04:12:11 2010 +0000
+++ b/pattern.rhope	Thu Dec 23 02:00:27 2010 +0000
@@ -87,7 +87,6 @@
 	out <- p
 }
 
-
 _Match@Empty Pattern[pattern,string,n:num,no match]
 {
 	no match <- Yes
@@ -129,4 +128,21 @@
 	}
 }
 
+_Partition@Pattern[delims,string:matched,after,not found]
+{
+        not found <- If[[string]=[""]] {}
+        {
+                [delims]Match[string]
+                {
+                        matched,after <- [string]Slice[~]
+                }{
+                        matched,after,not found <- _Partition[delims, [string]Substring[1, 0]]
+                }
+        }
+}
 
+_Partition@Empty Pattern[delims,string:matched,after,not found]
+{
+	not found <- Yes
+}
+