From d21900836f89b2bf9cd55ff1708a4619c8b89656 Mon Sep 17 00:00:00 2001 From: polwex Date: Mon, 20 Oct 2025 13:13:39 +0700 Subject: neoinit --- ocaml/scripts/show_pill.ml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 ocaml/scripts/show_pill.ml (limited to 'ocaml/scripts/show_pill.ml') diff --git a/ocaml/scripts/show_pill.ml b/ocaml/scripts/show_pill.ml new file mode 100644 index 0000000..07874fb --- /dev/null +++ b/ocaml/scripts/show_pill.ml @@ -0,0 +1,18 @@ +open Nock_lib + +let rec show noun depth limit = + if depth = 0 || limit = 0 then "..." + else match noun with + | Noun.Atom z -> Z.to_string z + | Noun.Cell (h, t) -> + Printf.sprintf "[%s %s]" (show h (depth-1) (limit-1)) (show t (depth-1) (limit-1)) + +let () = + if Array.length Sys.argv < 2 then exit 1; + let path = Sys.argv.(1) in + let ic = open_in_bin path in + let len = in_channel_length ic in + let data = really_input_string ic len in + close_in ic; + let noun = Serial.cue (Bytes.of_string data) in + Printf.printf "structure=%s\n" (show noun 6 100) -- cgit v1.2.3