Re: How to utop to print out really large lists.

"Gabriel Scherer [email protected] [ocaml_beginners]" <[email protected]> Fri, 5 Feb 2016 13:41:12 -0500
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <CAPFanBEPNWTFNXBJxSnhFV7faq4QLgesigfvmJuoSCjdVAj3-A@mail.gmail.com>
There are two directives to control toplevel printer cutoffs (see
http://caml.inria.fr/pub/docs/manual-ocaml/toplevel.html#sec256 )

#print_depth <int>
  Limit the printing of values to a maximal depth of n.
#print_length <int>
  Limit the number of value nodes printed to at most n.

The "depth" refers to the depth of nested datastructures. In your case, you
want to change #print_length.
For a list of length 1000,
  #print_length 1001;;
should work fine -- the list brackets count for 1, or something -- or any
higher value.

On Fri, Feb 5, 2016 at 1:04 PM, Douglas Lewit [email protected]
[ocaml_beginners] <[email protected]> wrote:

>
>
> Sorry about the bad English.  The title should have read, "How to
> *customize* utop to print out really large lists".  Sorry if the original
> title was a little confusing or misleading.
>
> On Fri, Feb 5, 2016 at 12:02 PM, Douglas Lewit [email protected]
> [ocaml_beginners] <[email protected]> wrote:
>
>>
>>
>> Hi everyone,
>>
>> So let's say that I'm using the following function to create a list of
>> random integers:
>>
>> *let rec randomList lower upper size = if size = 0 then [ ] else ( lower
>> + Random.int ( upper - lower + 1 )*
>> *:: ( randomList lower upper ( size - 1 ) ) ;;*
>>
>> The function works great!  I end up with a list of length size having
>> random integers in the range lower..upper ( including the endpoints of that
>> range ).  But here's the catch.
>>
>> Let's say that I do this:
>>
>> *let dougsList = randomList 1 1000 1000 ;;*
>>
>> Okay, great.... but if I'm using the *utop interface* for OCaml, then I
>> can only see about the first 350 ( approximately ) elements of my random
>> list.  Is there some setting in utop that I can change so that utop is
>> forced to print out the entire list for the sake of my visual inspection.
>> I realize that visually inspecting a list of 1,000 elements sounds rather
>> crazy and unrealistic, but the user of the interface should have that
>> option.
>>
>> Thanks for helping me solve this problem.
>>
>> Best,
>>
>> Douglas Lewit
>>
>>
>>
>
>
> 
>