blob: bdbc3065d73f8a59b5e47966411927b5d9c026c5 (
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
|
open Nock_lib.Noun
open Nock_lib.Serial
let () =
Printf.printf "# OCaml jam outputs (hex)\n";
(* Simple atoms *)
Printf.printf "0: %s\n" (bytes_to_hex (jam (atom 0)));
Printf.printf "1: %s\n" (bytes_to_hex (jam (atom 1)));
Printf.printf "2: %s\n" (bytes_to_hex (jam (atom 2)));
Printf.printf "42: %s\n" (bytes_to_hex (jam (atom 42)));
Printf.printf "255: %s\n" (bytes_to_hex (jam (atom 255)));
Printf.printf "256: %s\n" (bytes_to_hex (jam (atom 256)));
(* Simple cells *)
Printf.printf "[1 2]: %s\n" (bytes_to_hex (jam (cell (atom 1) (atom 2))));
Printf.printf "[0 0]: %s\n" (bytes_to_hex (jam (cell (atom 0) (atom 0))));
Printf.printf "[42 43]: %s\n" (bytes_to_hex (jam (cell (atom 42) (atom 43))));
(* Nested cells *)
Printf.printf "[[1 2] 3]: %s\n"
(bytes_to_hex (jam (cell (cell (atom 1) (atom 2)) (atom 3))));
Printf.printf "[1 [2 3]]: %s\n"
(bytes_to_hex (jam (cell (atom 1) (cell (atom 2) (atom 3)))));
(* Balanced tree *)
Printf.printf "[[1 2] [3 4]]: %s\n"
(bytes_to_hex (jam (cell (cell (atom 1) (atom 2)) (cell (atom 3) (atom 4)))));
(* Larger tree *)
Printf.printf "[[[1 2] [3 4]] [[5 6] [7 8]]]: %s\n"
(bytes_to_hex (jam (
cell
(cell (cell (atom 1) (atom 2)) (cell (atom 3) (atom 4)))
(cell (cell (atom 5) (atom 6)) (cell (atom 7) (atom 8)))
)))
|