1 (* Quick introduction to ML, session 3 *)
3 theory ML4_Datastructure imports Isac.Isac_Knowledge begin
5 text\<open>This course follows the book:
6 J.D.Ullmann, Elements of ML Programming. Prenctice Hall 1998.
10 datastructures are tuples and list already introduced, and two further datastructures in ML,
11 records and "datatypes"
13 section \<open>7.1 Record Structures\<close>
16 val wn = {firstname = "Walther", lastname = "Neuper", age = 62, male = true};
17 val tl = {firstname = "Thomas", lastname = "Leh", age = 17, male = true};
19 val {firstname, ...} = tl;
20 val {firstname = n, ...} = tl;
22 val {age = tage, ...} = tl;
25 section \<open>6.2 Datatypes\<close>
31 | op +++ of formula * formula
32 | op *** of formula * formula;
35 (Num 2 *** Num 3) +++ Num 4;
36 (Num 2 *** Num 3) +++ ((Num 2 *** Num 3) +++ Num 4);
39 (Num 2 *** Var "x") +++ ((Num 2 *** Num 3) +++ Var "c");
42 section \<open>Preview to Isabelle's terms\<close>
44 parse_test @{context};
45 parse_test @{context} "234 * bbb + ccc";