doc-src/Codegen/Thy/examples/lookup.ML
author krauss
Tue, 02 Aug 2011 11:52:57 +0200
changeset 44014 88bd7d74a2c1
parent 30226 2f4684e2ea95
permissions -rw-r--r--
moved recursion combinator to HOL/Library/Wfrec.thy -- it is so fundamental and well-known that it should survive recdef
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21147
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     1
structure ROOT = 
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     2
struct
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     3
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     4
structure Codegen = 
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     5
struct
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     6
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     7
fun lookup ((k, v) :: xs) l =
21994
dfa5133dbe73 updated manual
haftmann
parents: 21993
diff changeset
     8
  (if ((k : string) = l) then SOME v else lookup xs l)
dfa5133dbe73 updated manual
haftmann
parents: 21993
diff changeset
     9
  | lookup [] l = NONE;
21147
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    10
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    11
end; (*struct Codegen*)
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    12
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    13
end; (*struct ROOT*)