aboutsummaryrefslogtreecommitdiff
path: root/examples/tutorial.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2017-09-20 05:02:53 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2017-09-20 05:02:53 -0700
commit0750d642624b2262afdb4dd17b275a16e96971b5 (patch)
tree0d526e928115238862375441f5e4176638d07eb4 /examples/tutorial.nom
parent18365e02b14686e9ad26d1fbc5ac19984b73da6b (diff)
Updated all the code to work with the latest nomsu.
Diffstat (limited to 'examples/tutorial.nom')
-rw-r--r--examples/tutorial.nom29
1 files changed, 8 insertions, 21 deletions
diff --git a/examples/tutorial.nom b/examples/tutorial.nom
index 55e558b..306a0af 100644
--- a/examples/tutorial.nom
+++ b/examples/tutorial.nom
@@ -3,7 +3,7 @@
continue until dedent
# Import files like so:
-require "core.nom"
+require "lib/core.nom"
# Numbers:
23
@@ -114,8 +114,8 @@ do:
# Function definition:
rule [say both %first and also %second] =:
- # Function arguments are accessed just like variables
say %first
+ # Function arguments are accessed just like variables
say %second
# The last line of a function is the return value
@@ -192,29 +192,16 @@ say (2 ++ 3)
"say both %first and also %second", and a code block to a function called "rule % %"
that takes two arguments.
-# Line continuations work by either ending a line with ".." and continuing with an indented block:
-say..
- both "Tom" and
- also
- "Sawyer"
-
-# Or by starting the next line with ".."
+# Line continuations work by starting the next line with ".."
say both "Bruce"
..and also "Lee"
-# This can be mixed and matched:
-say both..
- "Rick"
-..and also..
- "Moranis"
-
-# And combined with the block forms of literals:
+# This can be combined with the block forms of literals:
say both ".."
|Four score and seven years ago our fathers brought forth, upon this continent,
|a new nation, conceived in liberty, and dedicated to the proposition that
|"all men are created equal"
-..and also..
- "-- Abraham Lincoln"
+..and also "-- Abraham Lincoln"
rule [my favorite number] =: 21 + 2
@@ -223,7 +210,7 @@ say (my favorite number)
# There's a multi-line indented block form for subexpressions too:
say (..)
my favorite
- number
+ ..number
# Block strings can interpolate values by enclosing an expression in a pair of \s
say ".."|My favorite number is \my favorite number\!
@@ -231,7 +218,7 @@ say ".."|My favorite number is \my favorite number\!
say ".."
|My favorite number is still \(..)
my favorite
- number
+ ..number
..\, but this time it uses an indented subexpression!
rule [sing %starting-bottles bottles of beer] =:
@@ -278,7 +265,7 @@ say ".."|The square root of 2 is \square root of 2\
# "macro block %" is for defining macros that produce blocks of code, not values
macro block [unless %condition %body] =: ".."
|if not (\%condition as lua expr\) then
- | \(lua expr "vars.body.value.value") as lua block\
+ | \(lua expr "vars.body.value") as lua block\
|end
unless (1 > 10):