Search code examples
ocamlread-eval-print-loopocaml-toplevel

How to show a list with large length in ocaml (toplevel)


I have created a list that contains a lot of elements in ocaml and I want to see whats inside it, but ocaml is only showing me a small part of it like this: [e1,e2,e3;...]. How can I configure ocaml to show everything?


Solution

  • You can see longer and deeper structures, interactively, with #print_length and #print_depth

    # #print_depth 0;;
    # [1;2;3;4];;
    - : int list = [...]
    
    # #print_depth 1;;
    # [[1];[2];[3];[4]];;
    - : int list list = [[...]; [...]; [...]; [...]]
    
    # #print_length 3;;
    # [1;2;3;4];;
    - : int list = [1; 2; ...]