1. Kota UENISHI
  2. ocaml-bert

Commits

UENISHI Kota  committed aa8b121

seems badly working.... orz.

  • Participants
  • Parent commits 19d1fed
  • Branches default

Comments (0)

Files changed (1)

File bert.ml

View file
  • Ignore whitespace
       | _ -> raise Unknown_type;
     end;;
 
+let print_binary bin = 
+  let rec p_bin i =
+    if i < (String.length bin) then begin
+      Printf.printf " %c" (String.get bin i);
+      p_bin (i+1)
+    end in
+    p_bin 0 ;;
+
 let print_erlterm term = 
-  print_endline " some term here:) ";;
+  let rec print_termlist rhs list =
+    begin match list with
+      | [] -> print_char rhs;
+      | a::[] -> begin 
+	  print_term a;
+	  print_char rhs;
+	end;
+      | hd::tl -> begin
+	  print_term hd;
+	  print_string ", ";   (* erlang way *)
+	  print_termlist rhs tl;
+	end;
+    end
+  and print_term t = 
+    begin match t with
+      | Int(i)-> Printf.printf "%d" i;
+      | Float(f)-> Printf.printf "%f" f;
+      | Tuple(tpl)-> begin
+	  print_char '{';  (* erlang way *)
+	  print_termlist '}' tpl;
+	end;
+      | List(list)-> begin
+	  print_char '[';    (* erlang way *)
+	  print_termlist ']' list; 
+	end;
+      | String(str)->
+	  print_string str;
+      | Binary(bin)-> begin
+	  print_string "<<";
+	  print_binary bin ;
+	  print_string ">>";
+	end;
+(*      | None ->
+	  print_string "Nil"; *)
+      | _->
+	  raise Unknown_type;
+    end in
+    print_term term;
+    print_char '.';;