factor/apps/benchmarks/ack.factor

20 lines
320 B
Factor
Raw Permalink Normal View History

2004-10-27 21:21:31 -04:00
USE: math
USE: kernel
USE: compiler
USE: test
! http://inferno.bell-labs.com/cm/cs/who/bwk/interps/pap.html
2004-11-08 22:36:51 -05:00
: ack ( m n -- x )
2006-01-28 15:49:31 -05:00
over zero? [
2005-09-16 22:47:28 -04:00
nip 1+
2004-10-27 21:21:31 -04:00
] [
2006-01-28 15:49:31 -05:00
dup zero? [
2005-09-16 22:47:28 -04:00
drop 1- 1 ack
2004-10-27 21:21:31 -04:00
] [
2005-09-16 22:47:28 -04:00
dupd 1- ack >r 1- r> ack
2005-09-24 15:21:17 -04:00
] if
] if ;
2004-10-27 21:21:31 -04:00
[ 4093 ] [ 3 9 ack ] unit-test