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
|
2005-01-13 19:49:47 -05:00
|
|
|
USE: namespaces
|
2004-12-17 19:27:42 -05:00
|
|
|
USE: compiler
|
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-12-10 21:39:27 -05:00
|
|
|
dup dup str-length 2 /i 0 swap rot substring
|
2004-12-29 03:35:46 -05:00
|
|
|
swap dup str-length 2 /i 1 + 1 swap rot substring cat2
|
2004-10-27 21:21:31 -04:00
|
|
|
string-step
|
|
|
|
] [
|
|
|
|
2drop
|
2004-12-17 19:27:42 -05:00
|
|
|
] ifte ; compiled
|
2004-10-27 21:21:31 -04:00
|
|
|
|
|
|
|
: string-benchmark ( n -- )
|
2004-12-17 19:27:42 -05:00
|
|
|
"abcdef" 10 [ 2dup string-step ] times 2drop ; compiled
|
2004-10-27 21:21:31 -04:00
|
|
|
|
|
|
|
[ ] [ 1000000 string-benchmark ] unit-test
|