[erlang-questions] Simple output questions

Bengt Kleberg bengt.kleberg@REDACTED
Wed Feb 21 08:22:18 CET 2007

On 2007-02-21 04:30, Josh Kupershmidt wrote:
> Hi all,
> I'm puzzling over how to output a long list of elements. My output
> seems to be getting chopped off after ~29 lines.
> For example, I have a function 'range' defined as:
> range(N, N) ->
>         [N];
> range(Min, Max) ->
>         [Min | range(Min+1, Max)].
> If I try to output integers between 1 and 100, the output gets chopped
> off at 29, ending with " 29|...] " .

the shell is truncating your list. write the list instead:
io:fwrite( "~w~n", [<module>:range(1, 100)] ).

> Another random question, is it possible to change the number of
> floating point significant digits. Mine seems to be set to 6. For
> example
> math:sqrt(2).
> Gives me "1.41421" . Any way to get more precision? Sorry if these
> questions are rather simple, I googled a bit without finding anything.

similarly the shells default setting is getting in your way. try
io:fwrite( "~.10g~n", [math:sqrt(2)] ).

i have never used this so see the manual page for io module where this 
is documented.

Those were the days...
    EPO guidelines 1978: "If the contribution to the known art resides
    solely in a computer program then the subject matter is not
    patentable in whatever manner it may be presented in the claims."

More information about the erlang-questions mailing list