[erlang-questions] escript cutting output

Bob Gustafson bobgus@REDACTED
Sat Nov 19 01:29:08 CET 2011


After spending too much time learning Erlang over the last few hours, I
think I have come up with a 'solution' to Matthias' well posed example
script. See below.

#!/usr/bin/env escript
  main(_) ->
    S = self(),
    spawn_link(fun() ->
       io:format("~p~p~n", [lists:duplicate(100000, $a), b]),
       io:format(""), %**
       S ! finished
    end),
    receive
      finished ->
          io:format(""), %**
          halt(0);
      _Other ->
          halt(1)
    end.

This script emits a string which *does* end in 'b'.

If you comment out either of the added lines followed by %**, then it
will emit a shorter string not ending in 'b'.

Bob G




More information about the erlang-questions mailing list