sequences.extras: adding "unsurround" word.

db4
John Benediktsson 2012-07-24 17:24:58 -07:00
parent eddc0326b7
commit 180cf219bc
2 changed files with 7 additions and 0 deletions

View File

@ -96,3 +96,7 @@ IN: sequences.extras.tests
{ t } [ "ABC" dup [ blank? ] ?trim [ identity-hashcode ] same? ] unit-test
{ "ABC" } [ " ABC " [ blank? ] ?trim ] unit-test
{ "" } [ "" "" "" unsurround ] unit-test
{ "" } [ " " " " " " unsurround ] unit-test
{ "foo.com" } [ "http://foo.com" "http://" "/" unsurround ] unit-test

View File

@ -213,3 +213,6 @@ PRIVATE>
over [ first-unsafe ] [ last-unsafe ] bi pick bi@ or
[ trim ] [ drop ] if
] if ; inline
: unsurround ( newseq seq2 seq3 -- seq1 )
[ ?head drop ] [ ?tail drop ] bi* ;