[Nickle] nickle: Branch 'master'

Bart Massey bart at keithp.com
Sun Nov 4 13:36:57 PST 2012


 doc/tutorial/tour/tour.sgml |   64 ++++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 32 deletions(-)

New commits:
commit ad5cf39a2ce4730cba665d862635506da99a5167
Author: Bart Massey <bart at cs.pdx.edu>
Date:   Sun Nov 4 13:37:06 2012 -0800

    corrected some Nickle Tour nits

diff --git a/doc/tutorial/tour/tour.sgml b/doc/tutorial/tour/tour.sgml
index 0e7bc4c..7c5d00e 100644
--- a/doc/tutorial/tour/tour.sgml
+++ b/doc/tutorial/tour/tour.sgml
@@ -4,9 +4,9 @@ $ nickle
 </screen>
 Arithmetic works as expected, with a rich set of operators.
 <screen>
-> 1+1
+> 1 + 1
 2
-> 2 ** (2+2)
+> 2 ** (2 + 2)
 16
 > 5!
 120
@@ -16,7 +16,7 @@ Math is done with infinite precision.
 Notice that integer division (//) is different from rational division (/).
 Nickle provides some conveniences, such as <literal>.</literal> denoting the last value printed.
 <screen>
-> 1/3
+> 1 / 3
 0.{3}
 > . * 3
 1
@@ -31,12 +31,12 @@ C-like control structures may also be used at the top level; the <literal>+</lit
 0
 > int y = x;
 > ++y;
-> for(int i=0; i<25; ++i)
-+   x+=0;
+> for(int i = 0; i < 25; i++)
++   x += 0;
 > x
 0
-> for(int i=1; i<9; i+=2)
-+   x+=i;
+> for(int i = 1; i < 9; i += 2)
++   x += i;
 > x
 16
 ]]></screen>
@@ -52,50 +52,50 @@ Imprecision is contagious; if a rational operator combines an imprecise variable
 2
 > sqrt(5)
 2.236067977499789
-> .**2
+> . ** 2
 4.999999999999999
-> ./5
+> . / 5
 0.999999999999999
 </screen>
 Functions can also be typed at the top level.
 Since functions, as most things, are first-class in Nickle, they may be declared and assigned as below.
 <screen>
-> real foo(real x,real y) {
-+   return x*y;
+> real foo(real x, real y) {
++   return x * y;
 + }
-> foo(2,3)
+> foo(2, 3)
 6
-> foo(4,2)
+> foo(4, 2)
 8
-> real(real,real) bar = foo;
-> bar(4,2)
+> real(real, real) bar = foo;
+> bar(4, 2)
 8
 > 
 </screen>
-Nickle is gauranteed never to dump core; it has a simple yet powerful exception system it uses to handle all errors.
+Nickle is guaranteed never to dump core; it has a simple yet powerful exception system it uses to handle all errors.
 An unhandled exception leads to the debugger, which uses a <literal>-</literal> prompt.
 The debugger can be used to trace the stack, move up and down on it, and check values of variables.
 <screen>
-> (-1) ** (1/2) 
-Unhandled exception "invalid_argument" at /u/p186/share/nickle/math.5c:13
-        "sqrt of negative number"
-        0
-        -1
-- trace
-    raise invalid_argument ("sqrt of negative number", 0, v);
-sqrt (-1)
-    result = sqrt (a);
-pow (-1, (1/2))
-    -1 ** (1 / 2)
+> (-1) ** (1/2)
+Unhandled exception invalid_argument ("sqrt of negative number", 0, -1)
+/usr/share/nickle/math.5c:19:     raise invalid_argument ("sqrt of negative number", 0, v);
+    sqrt (-1)
+/usr/share/nickle/math.5c:895:     result = sqrt (a);
+    pow (-1, 0.5)
+<stdin>:1:     -1 ** (1 / 2);
 - done
 > quit
 $
 </screen>
-Large chunks of code can be placed in a seperate text file and loaded when needed.
-The <literal>print</literal> command can be used to inspect variables, functions, namespaces, and other names.
-<literal>import</literal> brings the names in a namespace into scope.
-The <literal>::</literal> operator can be used to view those names without importing them.
-(These can also be used with several namespaces built in to Nickle, such as Math and File.)
+Large chunks of code can be placed in a separate text file
+and loaded when needed.  The <literal>print</literal>
+command can be used to inspect variables, functions,
+namespaces, and other names.
+<literal>import</literal> brings the names in a namespace
+into scope.  The <literal>::</literal> operator can be used
+to view those names without importing them.  (These can also
+be used with several namespaces built in to Nickle, such as
+Math and File.)
 <screen>
 $ nickle
 > load "cribbage.5c"


More information about the Nickle mailing list