summaryrefslogtreecommitdiff
path: root/examples/control.fy
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-15 23:28:07 +0000
committerPaul Buetow <paul@buetow.org>2008-05-15 23:28:07 +0000
commitbe839900419c7a74c4a46efd279d0ca16b35dc1f (patch)
tree1355c8f238d1c58ffd5cb8803bcc2adf987e79aa /examples/control.fy
parent33c945e58f86267b0d3bdca4c3421155e11eb0d9 (diff)
Moved stuff into trunk.
Diffstat (limited to 'examples/control.fy')
-rw-r--r--examples/control.fy32
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/control.fy b/examples/control.fy
new file mode 100644
index 0000000..0deac78
--- /dev/null
+++ b/examples/control.fy
@@ -0,0 +1,32 @@
+#*
+ * Examples of how to use control statements
+ *#
+
+if 1 {
+ say "if 1";
+}
+
+ifnot 0 == 1 {
+ say "ifnot 0 == 1";
+}
+
+# Calculate 10!
+
+my n = 10, fac = 0;
+
+while n > 1 {
+ ifnot fac {
+ fac = 1;
+ }
+ say fac = (fac * n);
+ decr n;
+}
+
+# Count up to 10
+
+n = 0;
+
+until n == 10 {
+ say incr n;
+}
+