comparison 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
comparison
equal deleted inserted replaced
155:d59611dcec71 156:ed70399a07aa
85 Pattern@Pattern[p:out] 85 Pattern@Pattern[p:out]
86 { 86 {
87 out <- p 87 out <- p
88 } 88 }
89 89
90
91 _Match@Empty Pattern[pattern,string,n:num,no match] 90 _Match@Empty Pattern[pattern,string,n:num,no match]
92 { 91 {
93 no match <- Yes 92 no match <- Yes
94 } 93 }
95 94
127 num, no match, idx <- [[pattern]Right >>]_Match[string, n,b] 126 num, no match, idx <- [[pattern]Right >>]_Match[string, n,b]
128 } 127 }
129 } 128 }
130 } 129 }
131 130
131 _Partition@Pattern[delims,string:matched,after,not found]
132 {
133 not found <- If[[string]=[""]] {}
134 {
135 [delims]Match[string]
136 {
137 matched,after <- [string]Slice[~]
138 }{
139 matched,after,not found <- _Partition[delims, [string]Substring[1, 0]]
140 }
141 }
142 }
132 143
144 _Partition@Empty Pattern[delims,string:matched,after,not found]
145 {
146 not found <- Yes
147 }
148