2004-10-27 21:21:31 -04:00
|
|
|
USE: strings
|
2004-12-10 19:29:07 -05:00
|
|
|
USE: kernel
|
2004-10-27 21:21:31 -04:00
|
|
|
USE: math
|
|
|
|
USE: test
|
2004-11-11 15:15:43 -05:00
|
|
|
USE: lists
|
2004-10-27 21:21:31 -04:00
|
|
|
|
|
|
|
! http://inferno.bell-labs.com/cm/cs/who/bwk/interps/pap.html
|
|
|
|
|
|
|
|
: string-step ( n str -- )
|
|
|
|
2dup str-length > [
|
2004-11-11 15:15:43 -05:00
|
|
|
dup [ "123" , , "456" , , "789" , ] make-string
|
2004-10-27 21:21:31 -04:00
|
|
|
dup dup str-length 2 /i 0 transp substring
|
|
|
|
swap dup str-length 2 /i succ 1 transp substring cat2
|
|
|
|
string-step
|
|
|
|
] [
|
|
|
|
2drop
|
|
|
|
] ifte ;
|
|
|
|
|
|
|
|
: string-benchmark ( n -- )
|
|
|
|
"abcdef" 10 [ 2dup string-step ] times 2drop ;
|
|
|
|
|
|
|
|
[ ] [ 1000000 string-benchmark ] unit-test
|