blob: 6e4e72df46afa1d5fd16d4adc556be37e7ad92f5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
(* Check the actual lifecycle formula structure *)
open Nock_lib
let () =
let formula = Noun.cell
(Noun.atom 2)
(Noun.cell
(Noun.cell (Noun.atom 0) (Noun.atom 3))
(Noun.cell (Noun.atom 0) (Noun.atom 2)))
in
Printf.printf "Lifecycle formula: [2 [0 3] [0 2]]\n";
Printf.printf "Formula is cell: %b\n" (Noun.is_cell formula);
let h = Noun.head formula in
let t = Noun.tail formula in
Printf.printf "Head (opcode): ";
(match h with
| Noun.Atom { z; _ } -> Printf.printf "atom %s\n" (Z.to_string z)
| Noun.Cell _ -> Printf.printf "cell\n");
Printf.printf "Tail (gal): cell\n";
let b_gal = Noun.head t in (* [0 3] *)
let c_gal = Noun.tail t in (* [0 2] *)
Printf.printf "b_gal ([0 3]): ";
(match b_gal with
| Noun.Atom _ -> Printf.printf "atom\n"
| Noun.Cell { h; t; _ } ->
Printf.printf "cell [";
(match h with Noun.Atom { z; _ } -> Printf.printf "%s " (Z.to_string z) | _ -> ());
(match t with Noun.Atom { z; _ } -> Printf.printf "%s" (Z.to_string z) | _ -> ());
Printf.printf "]\n");
Printf.printf "c_gal ([0 2]): ";
(match c_gal with
| Noun.Atom _ -> Printf.printf "atom\n"
| Noun.Cell { h; t; _ } ->
Printf.printf "cell [";
(match h with Noun.Atom { z; _ } -> Printf.printf "%s " (Z.to_string z) | _ -> ());
(match t with Noun.Atom { z; _ } -> Printf.printf "%s" (Z.to_string z) | _ -> ());
Printf.printf "]\n")
|