| 
									
										
										
										
											2016-03-30 21:43:14 -04:00
										 |  |  | USING: ascii kernel math sequences splitting strings tools.test ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-02 20:28:17 -04:00
										 |  |  | { "hello" "world ." } [ "hello world ." " " split1 ] unit-test | 
					
						
							|  |  |  | { "hello" "world-+." } [ "hello-+world-+." "-+" split1 ] unit-test | 
					
						
							|  |  |  | { "goodbye" f } [ "goodbye" " " split1 ] unit-test | 
					
						
							|  |  |  | { "" "" } [ "great" "great" split1 ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | { "hello world" "." } [ "hello world ." " " split1-last ] unit-test | 
					
						
							|  |  |  | { "hello-+world" "." } [ "hello-+world-+." "-+" split1-last ] unit-test | 
					
						
							|  |  |  | { "goodbye" f } [ "goodbye" " " split1-last ] unit-test | 
					
						
							|  |  |  | { "" "" } [ "great" "great" split1-last ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | { "hello world" "." } [ "hello world ." " " split1-last-slice [ >string ] bi@ ] unit-test | 
					
						
							|  |  |  | { "hello-+world" "." } [ "hello-+world-+." "-+" split1-last-slice [ >string ] bi@ ] unit-test | 
					
						
							|  |  |  | { "goodbye" f } [ "goodbye" " " split1-last-slice [ >string ] dip ] unit-test | 
					
						
							|  |  |  | { "" f } [ "great" "great" split1-last-slice [ >string ] dip ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | { "and end" t } [ "Beginning and end" "Beginning " ?head ] unit-test | 
					
						
							|  |  |  | { "Beginning and end" f } [ "Beginning and end" "Beginning x" ?head ] unit-test | 
					
						
							|  |  |  | { "Beginning and end" f } [ "Beginning and end" "eginning " ?head ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | { "Beginning" t } [ "Beginning and end" " and end" ?tail ] unit-test | 
					
						
							|  |  |  | { "Beginning and end" f } [ "Beginning and end" "Beginning x" ?tail ] unit-test | 
					
						
							|  |  |  | { "Beginning and end" f } [ "Beginning and end" "eginning " ?tail ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | { { "This" "is" "a" "split" "sentence" } } | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | [ "This is a split sentence" " " split ] | 
					
						
							|  |  |  | unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-02 20:28:17 -04:00
										 |  |  | { { "OneWord" } } | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | [ "OneWord" " " split ] | 
					
						
							|  |  |  | unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-02 20:28:17 -04:00
										 |  |  | { { "a" "b" "c" "d" "e" "f" } } | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | [ "aXbYcXdYeXf" "XY" split ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-02 20:28:17 -04:00
										 |  |  | { { "" "" } } | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | [ " " " " split ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-02 20:28:17 -04:00
										 |  |  | { { "hey" } } | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | [ "hey" " " split ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-02 20:28:17 -04:00
										 |  |  | { "Hello world" t } [ "Hello world\n" "\n" ?tail ] unit-test | 
					
						
							|  |  |  | { "Hello world" f } [ "Hello world" "\n" ?tail ] unit-test | 
					
						
							|  |  |  | { "" t } [ "\n" "\n" ?tail ] unit-test | 
					
						
							|  |  |  | { "" f } [ "" "\n" ?tail ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-13 18:46:04 -04:00
										 |  |  | { { } } [ "" string-lines ] unit-test | 
					
						
							|  |  |  | { { "" } } [ "\n" string-lines ] unit-test | 
					
						
							|  |  |  | { { "" } } [ "\r" string-lines ] unit-test | 
					
						
							|  |  |  | { { "" } } [ "\r\n" string-lines ] unit-test | 
					
						
							| 
									
										
										
										
											2015-07-02 20:28:17 -04:00
										 |  |  | { { "hello" } } [ "hello" string-lines ] unit-test | 
					
						
							| 
									
										
										
										
											2016-03-13 18:46:04 -04:00
										 |  |  | { { "hello" } } [ "hello\n" string-lines ] unit-test | 
					
						
							|  |  |  | { { "hello" } } [ "hello\r" string-lines ] unit-test | 
					
						
							|  |  |  | { { "hello" } } [ "hello\r\n" string-lines ] unit-test | 
					
						
							| 
									
										
										
										
											2015-07-02 20:28:17 -04:00
										 |  |  | { { "hello" "hi" } } [ "hello\nhi" string-lines ] unit-test | 
					
						
							|  |  |  | { { "hello" "hi" } } [ "hello\rhi" string-lines ] unit-test | 
					
						
							|  |  |  | { { "hello" "hi" } } [ "hello\r\nhi" string-lines ] unit-test | 
					
						
							| 
									
										
										
										
											2016-03-13 18:46:04 -04:00
										 |  |  | { { "hello" "" "" } } [ "hello\n\n\n" string-lines ] unit-test | 
					
						
							| 
									
										
										
										
											2015-07-02 20:28:17 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-13 18:46:04 -04:00
										 |  |  | { { } } [ SBUF" " string-lines ] unit-test | 
					
						
							|  |  |  | { { "" } } [ SBUF" \n" string-lines ] unit-test | 
					
						
							|  |  |  | { { "" } } [ SBUF" \r" string-lines ] unit-test | 
					
						
							|  |  |  | { { "" } } [ SBUF" \r\n" string-lines ] unit-test | 
					
						
							| 
									
										
										
										
											2015-07-02 20:28:17 -04:00
										 |  |  | { { "hello" } } [ SBUF" hello" string-lines ] unit-test | 
					
						
							| 
									
										
										
										
											2016-03-13 18:46:04 -04:00
										 |  |  | { { "hello" } } [ SBUF" hello\n" string-lines ] unit-test | 
					
						
							|  |  |  | { { "hello" } } [ SBUF" hello\r" string-lines ] unit-test | 
					
						
							|  |  |  | { { "hello" } } [ SBUF" hello\r\n" string-lines ] unit-test | 
					
						
							| 
									
										
										
										
											2015-07-02 20:28:17 -04:00
										 |  |  | { { "hello" "hi" } } [ SBUF" hello\nhi" string-lines ] unit-test | 
					
						
							|  |  |  | { { "hello" "hi" } } [ SBUF" hello\rhi" string-lines ] unit-test | 
					
						
							|  |  |  | { { "hello" "hi" } } [ SBUF" hello\r\nhi" string-lines ] unit-test | 
					
						
							| 
									
										
										
										
											2016-03-13 18:46:04 -04:00
										 |  |  | { { "hello" "" "" } } [ SBUF" hello\n\n\n" string-lines ] unit-test | 
					
						
							| 
									
										
										
										
											2015-07-02 20:28:17 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | { { "hey" "world" "what's" "happening" } } | 
					
						
							| 
									
										
										
										
											2009-11-06 17:29:33 -05:00
										 |  |  | [ "heyAworldBwhat'sChappening" [ LETTER? ] split-when ] unit-test | 
					
						
							| 
									
										
										
										
											2013-03-31 19:05:30 -04:00
										 |  |  | { { { 2 } { 3 } { 5 1 } { 7 } } } [ | 
					
						
							|  |  |  |     1 { 2 1 3 2 5 1 3 7 } | 
					
						
							|  |  |  |     [ dupd = dup [ [ 1 + ] dip ] when ] split-when nip
 | 
					
						
							|  |  |  | ] unit-test | 
					
						
							| 
									
										
										
										
											2012-04-18 18:55:15 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-02 20:28:17 -04:00
										 |  |  | { { "hey" "world" "what's" "happening" } } | 
					
						
							| 
									
										
										
										
											2013-03-27 19:00:16 -04:00
										 |  |  | [ | 
					
						
							|  |  |  |     "heyAworldBwhat'sChappening" [ LETTER? ] split-when-slice | 
					
						
							|  |  |  |     [ >string ] map
 | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-02 20:28:17 -04:00
										 |  |  | { "" f } [ "" [ blank? ] split1-when ] unit-test | 
					
						
							|  |  |  | { "" "ABC" } [ " ABC" [ blank? ] split1-when ] unit-test | 
					
						
							|  |  |  | { "a" " bc" } [ "a  bc" [ blank? ] split1-when ] unit-test | 
					
						
							| 
									
										
										
										
											2012-06-20 22:57:11 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-02 20:28:17 -04:00
										 |  |  | { "" f } [ "" [ blank? ] split1-when-slice ] unit-test | 
					
						
							|  |  |  | { "" "ABC" } [ " ABC" [ blank? ] split1-when-slice [ >string ] bi@ ] unit-test | 
					
						
							|  |  |  | { "a" " bc" } [ "a  bc" [ blank? ] split1-when-slice [ >string ] bi@ ] unit-test | 
					
						
							| 
									
										
										
										
											2013-03-27 19:00:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-03 19:42:34 -05:00
										 |  |  | { "abarbbarc" } | 
					
						
							|  |  |  | [ "afoobfooc" "foo" "bar" replace ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | { "abc" } | 
					
						
							|  |  |  | [ "afoobfooc" "foo" "" replace ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | { "afoobfooc" } | 
					
						
							|  |  |  | [ "afoobfooc" "" "bar" replace ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | { "afoobfooc" } | 
					
						
							|  |  |  | [ "afoobfooc" "" "" replace ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | { "" } [ "" "" "" replace ] unit-test | 
					
						
							| 
									
										
										
										
											2014-11-07 18:34:53 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | { { "Thi" "s " "i" "s a sequence" } } [ | 
					
						
							|  |  |  |     "This is a sequence" { 3 5 6 } split-indices | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | { { "" "This" } } [ | 
					
						
							|  |  |  |     "This" { 0 } split-indices | 
					
						
							|  |  |  | ] unit-test |