summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/factors-of-n.dsl12
-rw-r--r--examples/fizzbuzz.dumb2
2 files changed, 8 insertions, 6 deletions
diff --git a/examples/factors-of-n.dsl b/examples/factors-of-n.dsl
index a5ef2fc..9c6608f 100644
--- a/examples/factors-of-n.dsl
+++ b/examples/factors-of-n.dsl
@@ -5,15 +5,17 @@ PROC factors
''' find the smallest number that divides n '''
2 WHILE OVER OVER SWAP % 0 != DO 1 + END
''' print it and find the next factor '''
- DUP .
+ DUP PUT " " PUT
OVER OVER SWAP / factors
+ ELSE
+ "" PUTLN
END
END
PROC MAIN
- "Prime factors of 12:" . 12 factors
- "Prime factors of 5:" . 5 factors
- "Prime factors of 60:" . 60 factors
- "Prime factors of 97:" . 97 factors
+ "Prime factors of 12:" PUTLN 12 factors
+ "Prime factors of 5:" PUTLN 5 factors
+ "Prime factors of 60:" PUTLN 60 factors
+ "Prime factors of 97:" PUTLN 97 factors
END
diff --git a/examples/fizzbuzz.dumb b/examples/fizzbuzz.dumb
index f9aa648..3cd0dba 100644
--- a/examples/fizzbuzz.dumb
+++ b/examples/fizzbuzz.dumb
@@ -10,6 +10,6 @@ PROC MAIN
''' concat the two strings and copy the inc., if the string is empty, swap them '''
++ OVER SWAP IF DUP "" == DO SWAP END
''' print the top of the stack, drop the next item, add 1 to inc. '''
- . DROP 1 +
+ PUTLN DROP 1 +
END
END