diff doc/intro.ur @ 1499:92c929793d0f

Preserve tutorial indentation
author Adam Chlipala <adam@chlipala.net>
date Fri, 15 Jul 2011 19:00:59 -0400
parents 8c32c7191bf0
children 483cc0602565
line wrap: on
line diff
--- 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 *)