Fib program, deleted commented exercise test code
This commit is contained in:
47
bin/main.ml
47
bin/main.ml
@ -1,20 +1,3 @@
|
|||||||
(*
|
|
||||||
|
|
||||||
open Lang.Exercises
|
|
||||||
(* let () = Printf.printf "%d\n" (eval_a_exp (Of_bool (Bval true))); *)
|
|
||||||
|
|
||||||
let myfsa: fsa = {vertices = (StringMap.add "node 2" true (StringMap.singleton "node 1" false));
|
|
||||||
edges = (StringMap.add "node 2" ("node 2", 'b') (StringMap.singleton "node 1" ("node 2", 'a')));
|
|
||||||
state = "node 1"}
|
|
||||||
|
|
||||||
let mystr = ['a'; 'b'; 'a'; 'b']
|
|
||||||
|
|
||||||
let ret = (Lang.Exercises.ex8 mystr myfsa);;
|
|
||||||
if ret
|
|
||||||
then print_endline "true"
|
|
||||||
else print_endline "false"
|
|
||||||
|
|
||||||
*)
|
|
||||||
open Lang.MiniImp
|
open Lang.MiniImp
|
||||||
|
|
||||||
(* -------------------------------------------------------------------------- *)
|
(* -------------------------------------------------------------------------- *)
|
||||||
@ -137,3 +120,33 @@ let program =
|
|||||||
|
|
||||||
Printf.printf "%d\n" (reduce 10 program)
|
Printf.printf "%d\n" (reduce 10 program)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
(* -------------------------------------------------------------------------- *)
|
||||||
|
(* rand program *)
|
||||||
|
let program =
|
||||||
|
Main
|
||||||
|
("n",
|
||||||
|
"fnext",
|
||||||
|
(Sequence (
|
||||||
|
Sequence (
|
||||||
|
(Assignment ("fnow", Integer 0)),
|
||||||
|
(Assignment ("fnext", Integer 1))
|
||||||
|
),
|
||||||
|
(While (
|
||||||
|
(BCmpGreater (Variable "n", Integer 1)),
|
||||||
|
(Sequence (
|
||||||
|
(Sequence (
|
||||||
|
(Assignment ("tmp", Plus (Variable "fnow", Variable "fnext"))),
|
||||||
|
(Assignment ("fnow", Variable "fnext"))
|
||||||
|
)),
|
||||||
|
(Sequence (
|
||||||
|
(Assignment ("fnext", Variable "tmp")),
|
||||||
|
(Assignment ("n", Minus (Variable "n", Integer 1)))
|
||||||
|
))
|
||||||
|
))))
|
||||||
|
))
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
|
||||||
|
Printf.printf "%d\n" (reduce 48 program)
|
||||||
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user