# HG changeset patch # User Adam Chlipala # Date 1310770859 14400 # Node ID 92c929793d0fc5e427944da436606326473963b4 # Parent 8c32c7191bf04e3aa5d9450524c723d430b1c5e0 Preserve tutorial indentation diff -r 8c32c7191bf0 -r 92c929793d0f doc/intro.ur --- a/doc/intro.ur Fri Jul 15 18:55:58 2011 -0400 +++ b/doc/intro.ur Fri Jul 15 19:00:59 2011 -0400 @@ -74,7 +74,7 @@ compose inc inc 3 (* end *) -(* The "option" type family is like ML's "option" or Haskell's "maybe." Note that, while Ur follows most syntactic conventions of ML, one key difference is that type families appear before their arguments, as in Haskell. *) +(* The "option" type family is like ML's "option" or Haskell's "maybe." We also have a "case" expression form lifted directly from ML. Note that, while Ur follows most syntactic conventions of ML, one key difference is that type families appear before their arguments, as in Haskell. *) fun predecessor (n : int) : option int = if n >= 1 then Some (n - 1) else None @@ -92,3 +92,21 @@ (* begin eval *) predecessor 0 (* end *) + +(* Naturally, there are lists, too! *) + +val numbers : list int = 1 :: 2 :: 3 :: [] +val strings : list string = "a" :: "bc" :: [] + +fun length [a] (ls : list a) : int = + case ls of + [] => 0 + | _ :: ls' => 1 + length ls' + +(* begin eval *) +length numbers +(* end *) + +(* begin eval *) +length strings +(* end *) diff -r 8c32c7191bf0 -r 92c929793d0f src/tutorial.sml --- a/src/tutorial.sml Fri Jul 15 18:55:58 2011 -0400 +++ b/src/tutorial.sml Fri Jul 15 19:00:59 2011 -0400 @@ -182,6 +182,7 @@ | #"{" => "{" | #"(" => "(" | #"\n" => "(*NL*)\n" + | #" " => "(*NL*) " | ch => str ch) o Substring.string val (befor, after) = Substring.position "(* begin " source