USING: accessors arrays ascii io io.streams.string kernel make
-math math.vectors random sequences sequences.extras strings
-tools.test vectors vocabs ;
+math prettyprint sequences sequences.extras strings tools.test ;
{ V{ { 0 104 } { 2 108 } { 3 108 } } } [ "hello" [ even? ] find-all ] unit-test
{ { 2 4 6 } } [ { 1 2 3 4 5 6 } odd-indices ] unit-test
{ "a b c d e" }
-[ "a b \t \n \r c d \n e " [ blank? ] " " compact ] unit-test
+[ "a b \t \n \r c d \n e " [ ascii:blank? ] " " compact ] unit-test
{ " a b c d e " }
-[ " a b c d e " [ blank? ] " " collapse ] unit-test
+[ " a b c d e " [ ascii:blank? ] " " collapse ] unit-test
{ { "hello," " " "world!" " " " " } }
-[ "hello, world! " [ blank? ] slice-when [ >string ] map ] unit-test
+[ "hello, world! " [ ascii:blank? ] slice-when [ >string ] map ] unit-test
{ t }
[ "abc" sequence>slice slice? ] unit-test
{ "ADEBFC" } [ { "ABC" "D" "EF" } round-robin >string ] unit-test
{ { } } [ "ABC" [ ] { } trim-as ] unit-test
-{ "ABC" } [ { 32 65 66 67 32 } [ blank? ] "" trim-as ] unit-test
+{ "ABC" } [ { 32 65 66 67 32 } [ ascii:blank? ] "" trim-as ] unit-test
-{ t } [ "ABC" dup [ blank? ] ?trim [ identity-hashcode ] same? ] unit-test
-{ "ABC" } [ " ABC " [ blank? ] ?trim ] unit-test
+{ t } [ "ABC" dup [ ascii:blank? ] ?trim [ identity-hashcode ] same? ] unit-test
+{ "ABC" } [ " ABC " [ ascii:blank? ] ?trim ] unit-test
-{ t } [ "ABC" dup [ blank? ] ?trim-head [ identity-hashcode ] same? ] unit-test
-{ t } [ "ABC" dup [ blank? ] ?trim-tail [ identity-hashcode ] same? ] unit-test
-{ "ABC " } [ " ABC " [ blank? ] ?trim-head ] unit-test
-{ " ABC" } [ " ABC " [ blank? ] ?trim-tail ] unit-test
+{ t } [ "ABC" dup [ ascii:blank? ] ?trim-head [ identity-hashcode ] same? ] unit-test
+{ t } [ "ABC" dup [ ascii:blank? ] ?trim-tail [ identity-hashcode ] same? ] unit-test
+{ "ABC " } [ " ABC " [ ascii:blank? ] ?trim-head ] unit-test
+{ " ABC" } [ " ABC " [ ascii:blank? ] ?trim-tail ] unit-test
{ "" } [ "" "" "" unsurround ] unit-test
{ "" } [ " " " " " " unsurround ] unit-test
{ "cdef" } [ 2 f "abcdef" subseq* ] unit-test
{ "cd" } [ -4 -2 "abcdef" subseq* ] unit-test
-{ "foo" "" } [ "foo" [ blank? ] cut-when ] unit-test
-{ "foo" " " } [ "foo " [ blank? ] cut-when ] unit-test
-{ "" " foo" } [ " foo" [ blank? ] cut-when ] unit-test
-{ "foo" " bar" } [ "foo bar" [ blank? ] cut-when ] unit-test
+{ "foo" "" } [ "foo" [ ascii:blank? ] cut-when ] unit-test
+{ "foo" " " } [ "foo " [ ascii:blank? ] cut-when ] unit-test
+{ "" " foo" } [ " foo" [ ascii:blank? ] cut-when ] unit-test
+{ "foo" " bar" } [ "foo bar" [ ascii:blank? ] cut-when ] unit-test
{ { 4 0 3 1 2 } } [ { 0 4 1 3 2 } 5 <iota> [ nth* ] curry map ] unit-test
{ 25 5 1 } [ { 4 5 6 } [ sq ] [ 20 > ] find-pred ] unit-test
{ f f f } [ { 4 5 6 } [ sq ] [ 200 > ] find-pred ] unit-test
+
+{ -1/0. } [ { } max-subarray-sum ] unit-test
+{ -2 } [ { -3 -2 } max-subarray-sum ] unit-test
+{ 7 } [ { 1 2 3 -4 5 } max-subarray-sum ] unit-test
+{ 6 } [ { 1 2 3 -4 1 1 } max-subarray-sum ] unit-test
+
+{ { 9 7 5 } } [ -1 -6 -2 10 <iota> <step-slice> >array ] unit-test
+{ { 9 7 } } [ -1 -5 -2 10 <iota> <step-slice> >array ] unit-test
+{ { 9 7 } } [ -1 -4 -2 10 <iota> <step-slice> >array ] unit-test
+{ { 9 } } [ -1 -3 -2 10 <iota> <step-slice> >array ] unit-test
+{ { } } [ -4 10 -2 10 <iota> <step-slice> >array ] unit-test
+{ { 6 8 } } [ -4 15 2 10 <iota> <step-slice> >array ] unit-test
+{ { 1 3 } } [ 1 4 2 10 <iota> <step-slice> >array ] unit-test
+{ { 1 3 } } [ 1 5 2 10 <iota> <step-slice> >array ] unit-test
+{ { 1 3 5 } } [ 1 6 2 10 <iota> <step-slice> >array ] unit-test
+
+{ { 102 306 1530 } } [
+ { 2 3 5 } [ swap [ * ] [ 100 + ] if* ] map-with-previous
+] unit-test
+
+{ { } } [
+ { } [ nip ] map-with-previous
+] unit-test
+
+{ { -1 2 -3 4 -5 } } [ { 1 2 3 4 5 } [ odd? ] [ neg ] map-if ] unit-test
+
+{ { { 100 0 } { 200 1 } { 300 2 } { 400 3 } } } [
+ { 100 200 300 400 } <zip-index> >array
+] unit-test
+
+{ } [
+ { } [ - . ] each-prior
+] unit-test
+
+{ } [
+ { 5 16 42 103 } [ - . ] each-prior
+] unit-test
+
+{ { } } [
+ { } [ - ] map-prior
+] unit-test
+
+{ V{ 5 11 26 61 } } [
+ V{ 5 16 42 103 } [ - ] map-prior
+] unit-test
+
+{ V{ } } [
+ { } [ - ] V{ } map-prior-as
+] unit-test
+
+{ { 5 11 26 61 } } [
+ V{ 5 16 42 103 } [ - ] { } map-prior-as
+] unit-test
+
+{ f } [ 0 CHAR: a "foo" nth-index ] unit-test
+{ 0 } [ 0 CHAR: a "abba" nth-index ] unit-test
+{ 3 } [ 1 CHAR: a "abba" nth-index ] unit-test
+{ f } [ 2 CHAR: a "abba" nth-index ] unit-test