From 649319b1dafb130801638c5a156e37d9e865ba5c Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sat, 29 Jan 2022 23:11:03 +0200 Subject: Implement strings as phrases of chars --- samples/modulo.sample | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'samples/modulo.sample') diff --git a/samples/modulo.sample b/samples/modulo.sample index 235d135..b093015 100644 --- a/samples/modulo.sample +++ b/samples/modulo.sample @@ -1,5 +1,12 @@ +define decrement + dup $decrement_var ! + @ 1 - $decrement_var @ ! + $decrement_var forget ; + 10 $idx ! -[ $idx @ dup 0 gt? ] - [ 2 mod 0 eq? . - $idx @ 1 - $idx ! ] loop -drop \ No newline at end of file +[ $idx @ dup 0 gt? ] -- while idx > 0 + [ 2 mod 0 eq? -- print "even" if even, "odd" if odd + [ "even" s. ] + [ "odd" s. ] cond + $idx decrement ] loop -- decrement idx by 1 +drop -- cgit v1.3