summaryrefslogtreecommitdiff
path: root/examples/factors-of-n.dsl
diff options
context:
space:
mode:
authorMatthew Hall <hallmatthew314@gmail.com>2023-02-24 23:03:33 +1300
committerMatthew Hall <hallmatthew314@gmail.com>2023-02-24 23:03:33 +1300
commit1977b7ad1e86d2b922737eb04741607e9c9a991a (patch)
tree24653cb78f5411e79d1ede853115ca38ccd80aa4 /examples/factors-of-n.dsl
parentb89d46e7df8ae65786abe37b5703392e9042db83 (diff)
Better printing functionsmain
Diffstat (limited to 'examples/factors-of-n.dsl')
-rw-r--r--examples/factors-of-n.dsl12
1 files changed, 7 insertions, 5 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