Reputation: 33
Is it possible to print a data structure in F#
without abbreviating long lists?
With printf I can only seem to print the first 100 elements:
\> let l = [1 .. 200];;
val l : int list =
[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; 37; 38; 39; 40;
41; 42; 43; 44; 45; 46; 47; 48; 49; 50; 51; 52; 53; 54; 55; 56; 57; 58; 59;
60; 61; 62; 63; 64; 65; 66; 67; 68; 69; 70; 71; 72; 73; 74; 75; 76; 77; 78;
79; 80; 81; 82; 83; 84; 85; 86; 87; 88; 89; 90; 91; 92; 93; 94; 95; 96; 97;
98; 99; 100; ...]
\> printf "%A\n" l;;
[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; 37; 38; 39; 40; 41; 42;
43; 44; 45; 46; 47; 48; 49; 50; 51; 52; 53; 54; 55; 56; 57; 58; 59; 60; 61; 62;
63; 64; 65; 66; 67; 68; 69; 70; 71; 72; 73; 74; 75; 76; 77; 78; 79; 80; 81; 82;
83; 84; 85; 86; 87; 88; 89; 90; 91; 92; 93; 94; 95; 96; 97; 98; 99; 100; ...]
val it : unit = ()
In this case it would be possible to loop through the elements, however, in a more complicated data structure it would be necessary to decompose the structure to allow access to the lists.
For example, is it possible to print the following structure in its entirety without breaking it down into individual lists:
\> let l = ([1 ..200], [1..200]);;
?
Upvotes: 3
Views: 383
Reputation: 243041
You can use the PrintLength
property of the fsi
object to specify maximal length for printing lists. It doesn't allow you to specify infinity directly, but you can use:
fsi.PrintLength <- System.Int32.MaxValue
There are several similar properties, but they aren't documented very well (see the MSDN page), so you'll probably need to experiment a bit.
Upvotes: 4