The escript shape in Erlang
The smallest Erlang script: main/1 and io:format directives.
%% An escript runs main/1; io:format prints with ~ directives.
main(_) ->
Exchange = "Kettle Street",
Lines = 24,
io:format("Exchange ~s on shift~n", [Exchange]),
io:format("Lines available: ~p~n", [Lines]),
io:format("Pairs if fully patched: ~p~n", [Lines div 2]).
How it works
- An escript runs
main/1; the first line is always a comment. ~sformats strings,~ppretty-prints any term.divis integer division —/would answer a float.
Keywords and builtins used here
formatmain
The run, in numbers
- Lines
- 7
- Characters to type
- 265
- Tokens
- 65
- Three-star pace
- 70 tpm
At the three-star pace of 70 tokens a minute, this run takes about 56 seconds.
Step 1 of 3 in Values, step 1 of 31 in Language basics.