Last login: Thu Apr 18 23:12:25 on ttys000

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
(base) ex-apc3:erl 2023 bruni$ erl
Erlang/OTP 26 [erts-14.0.2] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit:ns] [dtrace]

Eshell V14.0.2 (press Ctrl+G to abort, type help(). for help)
1> 2 + 15.
17
2> 49 * 100.
4900
3> 5 / 2.
2.5
4> 5 div 2.
2
5> 5 rem 2.
1
6> monday.
monday
7> 'monday'.            
monday
8> 'hello \n my friend'.
'hello \n my friend'
9> {a,b,c}.
{a,b,c}
10> [a,b,c].
[a,b,c]
11> "abc".
"abc"
12> [97,98,99].
"abc"
13> [97,98,99,7].
[97,98,99,7]
14> true.
true
15> false.
false
16> true and false.
false
17> false or true.
true
18> not false.
true
19> true xor false.
true
20> true and pippo.
** exception error: bad argument
     in operator  and/2
        called as true and pippo
21> true orelse pippo.
true
22> false andalso pippo.
false
23> One.
* 1:1: variable 'One' is unbound
24> One = 1.
1
25> One = 2.
** exception error: no match of right hand side value 2
26> Un = Ein = Uno = One = 1.
1
27> b().
Ein = 1
One = 1
Un = 1
Uno = 1
ok
28> f(Ein).
ok
29> b().
One = 1
Un = 1
Uno = 1
ok
30> Two = One + One.
2
31> Two = 2.
2
32> f().
ok
33> b().
ok
34> help().
** shell internal commands **
b()        -- display all variable bindings
e(N)       -- repeat the expression in query <N>
f()        -- forget all variable bindings
f(X)       -- forget the binding of variable X
h()        -- history
h(Mod)     -- help about module
h(Mod,Func)-- help about function in module
h(Mod,Func,Arity) -- help about function with arity in module
ht(Mod)    -- help about a module's types
ht(Mod,Type) -- help about type in module
ht(Mod,Type,Arity) -- help about type with arity in module
hcb(Mod)    -- help about a module's callbacks
hcb(Mod,CB) -- help about callback in module
hcb(Mod,CB,Arity) -- help about callback with arity in module
history(N) -- set how many previous commands to keep
results(N) -- set how many previous command results to keep
catch_exception(B) -- how exceptions are handled
v(N)       -- use the value of query <N>
rd(R,D)    -- define a record
rf()       -- remove all record information
rf(R)      -- remove record information about R
rl()       -- display all record information
rl(R)      -- display record information about R
rp(Term)   -- display Term using the shell's record information
rr(File)   -- read record information from File (wildcards allowed)
rr(F,R)    -- read selected record information from file(s)
rr(F,R,O)  -- read selected record information with options
** commands in module c **
bt(Pid)    -- stack backtrace for a process
c(Mod)     -- compile and load module or file <Mod>
cd(Dir)    -- change working directory
flush()    -- flush any messages sent to the shell
help()     -- help info
h(M)       -- module documentation
h(M,F)     -- module function documentation
h(M,F,A)   -- module function arity documentation
i()        -- information about the system
ni()       -- information about the networked system
i(X,Y,Z)   -- information about pid <X,Y,Z>
l(Module)  -- load or reload module
lm()       -- load all modified modules
lc([File]) -- compile a list of Erlang modules
ls()       -- list files in the current directory
ls(Dir)    -- list files in directory <Dir>
m()        -- which modules are loaded
m(Mod)     -- information about module <Mod>
mm()       -- list all modified modules
memory()   -- memory allocation information
memory(T)  -- memory allocation information of type <T>
nc(File)   -- compile and load code in <File> on all nodes
nl(Module) -- load module on all nodes
pid(X,Y,Z) -- convert X,Y,Z to a Pid
pwd()      -- print working directory
q()        -- quit - shorthand for init:stop()
regs()     -- information about registered processes
nregs()    -- information about all registered processes
uptime()   -- print node uptime
xm(M)      -- cross reference check a module
y(File)    -- generate a Yecc parser
** commands in module i (interpreter interface) **
ih()       -- print help for the i module
true
35> 4 > 3.
true
36> 4 < 5.
true
37> 4 >= 3.
true
38> 4 <= 5.
* 1:3: syntax error before: '<='
38> 4 =< 5.
true
39> 3 == 3.
true
40> 3 /= 3.
false
41> 3 == 3.0.
true
42> 3 /= 3.0.
false
43> 3 =:= 3.0.
false
44> 3 =/= 3.0.
true
45> % number < atom < fun < pid < tuple < list .
 .. .
* 2:1: syntax error before: '.'
45> 1 < a.
true
46> a < {a}.
true
47> {a} < [a].
true
48> X=10, Y=4.
4
49> Point = {X,Y}.
{10,4}
50> {A,B} = Point.
{10,4}
51> b().
A = 10
B = 4
Point = {10,4}
X = 10
Y = 4
ok
52> {A1,_} = Point.
{10,4}
53> A1.
10
54> {_,_} = {1,2,3}.
** exception error: no match of right hand side value {1,2,3}
55> [1, 2, 3, {numbers,[4,5,6]}, 5.34, atomo].
[1,2,3,{numbers,[4,5,6]},5.34,atomo]
56> [1,2,3] ++ [4,5].
[1,2,3,4,5]
57> [1,2,3,4,5] -- [1,4].
[2,3,5]
58> [1,2,3,1,2,3] -- [1,1,2].
[3,2,3]
59> [1,2,3,1,2,3] -- [1,1,2,5].
[3,2,3]
60> [1,2,3] -- [1,2] -- [3].
[3]
61> ([1,2,3] -- [1,2]) -- [3].
[]
62> hd([1,2,3,4,5]).
1
63> tl([1,2,3,4,5]).
[2,3,4,5]
64> length([1,2,3,4,5]).
5
65> List = [2,3,4].
[2,3,4]
66> NewList = [1|List].
[1,2,3,4]
67> [Head|Tail] = NewList.
[1,2,3,4]
68> b().
A = 10
A1 = 10
B = 4
Head = 1
List = [2,3,4]
NewList = [1,2,3,4]
Point = {10,4}
Tail = [2,3,4]
X = 10
Y = 4
ok
69> [1 | [2 | [3 | [] ] ] ].
[1,2,3]
70> [1|2].
[1|2]
71> [I,J] = [1|[2]].
[1,2]
72> [I,J] = [1|2].  
** exception error: no match of right hand side value [1|2]
73> [I1,J1] = [1|2].
** exception error: no match of right hand side value [1|2]
74> [I1|J1] = [1|2].
[1|2]
75> b().
A = 10
A1 = 10
B = 4
Head = 1
I = 1
I1 = 1
J = 2
J1 = 2
List = [2,3,4]
NewList = [1,2,3,4]
Point = {10,4}
Tail = [2,3,4]
X = 10
Y = 4
ok
76> [2*N || N <- [1,2,3]].
[2,4,6]
77> Z = [ {X,Y} || X <- [a,b,c], Y <- [1,2,3,4] ].
[{a,1},
 {a,2},
 {a,3},
 {a,4},
 {b,1},
 {b,2},
 {b,3},
 {b,4},
 {c,1},
 {c,2},
 {c,3},
 {c,4}]
78> [ X || {a,X} <- Z ].
[1,2,3,4]
79> erlang:element(2,{a,b,c}).
b
80> element(2,{a,b,c}).  
b
81> lists:seq(1,10).
[1,2,3,4,5,6,7,8,9,10]
82> seq(1,10).  
** exception error: undefined shell command seq/2
83> c(adders).
{ok,adders}
84> adders:add(1,2,3).
6
85> c(functions).
functions.erl:2:2: Warning: export_all flag enabled - all functions will be exported
%    2| -compile(export_all).
%     |  ^

{ok,functions}
86> functions:greet(male,andrea).
Hello, Mr. andrea!
ok
87> functions:greet(female,andrea).
Hello, Mrs. andrea!
ok
88> functions:greet(child,andrea). 
Hello, andrea!
ok
89> functions:second([1,2]).
2
90> functions:second([2]).  
** exception error: no function clause matching functions:second([2]) (functions.erl, line 37)
91> functions:same(3,3).
true
92> functions:same(3,4).
false
93> functions:old_enough(78).
true
94> functions:old_enough(8). 
false
95> functions:add(fun functions:one/0 , fun functions:two/0).
3
96> Succ = fun(X) -> X+1 end.
#Fun<erl_eval.42.125776118>
97> functions:apply(Succ,3).
4
98> lists:map(Succ,[1,2,3]).
[2,3,4]
99> c(recursion).
recursion.erl:2:2: Warning: export_all flag enabled - all functions will be exported
%    2| -compile(export_all).
%     |  ^

{ok,recursion}
100> recursion:perms("abc").
["abc","acb","bac","bca","cab","cba"]
101> recursion:perms("abcdef").
["abcdef","abcdfe","abcedf","abcefd","abcfde","abcfed",
 "abdcef","abdcfe","abdecf","abdefc","abdfce","abdfec",
 "abecdf","abecfd","abedcf","abedfc","abefcd","abefdc",
 "abfcde","abfced","abfdce","abfdec","abfecd","abfedc",
 "acbdef","acbdfe","acbedf","acbefd",
 [...]|...]
102> F = fun() -> 2 + 2 end.
#Fun<erl_eval.43.125776118>
103> spawn(F).
<0.210.0>
104> self().
<0.192.0>
105> G = fun (X) ->
  ..     timer:sleep(200-X),
  ..     io:format("~p says ~p~n",[self(),X])
  ..     end.
#Fun<erl_eval.42.125776118>
106> G(5).
<0.192.0> says 5
ok
107> [spawn(fun() -> G(X) end) || X <- lists:seq(1,30)].
[<0.215.0>,<0.216.0>,<0.217.0>,<0.218.0>,<0.219.0>,
 <0.220.0>,<0.221.0>,<0.222.0>,<0.223.0>,<0.224.0>,<0.225.0>,
 <0.226.0>,<0.227.0>,<0.228.0>,<0.229.0>,<0.230.0>,<0.231.0>,
 <0.232.0>,<0.233.0>,<0.234.0>,<0.235.0>,<0.236.0>,<0.237.0>,
 <0.238.0>,<0.239.0>,<0.240.0>,<0.241.0>,<0.242.0>,<0.243.0>|...]
<0.244.0> says 30
<0.243.0> says 29
<0.242.0> says 28
<0.241.0> says 27
<0.240.0> says 26
<0.239.0> says 25
<0.238.0> says 24
<0.237.0> says 23
<0.236.0> says 22
<0.235.0> says 21
<0.234.0> says 20
<0.233.0> says 19
<0.232.0> says 18
<0.231.0> says 17
<0.230.0> says 16
<0.229.0> says 15
<0.228.0> says 14
<0.227.0> says 13
<0.226.0> says 12
<0.225.0> says 11
<0.224.0> says 10
<0.223.0> says 9
<0.222.0> says 8
<0.221.0> says 7
<0.220.0> says 6
<0.219.0> says 5
<0.218.0> says 4
<0.217.0> says 3
<0.216.0> says 2
<0.215.0> says 1
108> [spawn(fun() -> G(X) end) || X <- lists:seq(1,50)].
[<0.246.0>,<0.247.0>,<0.248.0>,<0.249.0>,<0.250.0>,
 <0.251.0>,<0.252.0>,<0.253.0>,<0.254.0>,<0.255.0>,<0.256.0>,
 <0.257.0>,<0.258.0>,<0.259.0>,<0.260.0>,<0.261.0>,<0.262.0>,
 <0.263.0>,<0.264.0>,<0.265.0>,<0.266.0>,<0.267.0>,<0.268.0>,
 <0.269.0>,<0.270.0>,<0.271.0>,<0.272.0>,<0.273.0>,<0.274.0>|...]
<0.295.0> says 50
<0.294.0> says 49
<0.293.0> says 48
<0.292.0> says 47
<0.291.0> says 46
<0.290.0> says 45
<0.289.0> says 44
<0.288.0> says 43
<0.287.0> says 42
<0.286.0> says 41
<0.284.0> says 39
<0.285.0> says 40
<0.283.0> says 38
<0.282.0> says 37
<0.281.0> says 36
<0.280.0> says 35
<0.279.0> says 34
<0.278.0> says 33
<0.277.0> says 32
<0.276.0> says 31
<0.275.0> says 30
<0.274.0> says 29
<0.273.0> says 28
<0.272.0> says 27
<0.271.0> says 26
<0.270.0> says 25
<0.269.0> says 24
<0.268.0> says 23
<0.267.0> says 22
<0.266.0> says 21
<0.265.0> says 20
<0.264.0> says 19
<0.263.0> says 18
<0.262.0> says 17
<0.261.0> says 16
<0.260.0> says 15
<0.259.0> says 14
<0.258.0> says 13
<0.257.0> says 12
<0.256.0> says 11
<0.254.0> says 9
<0.255.0> says 10
<0.253.0> says 8
<0.252.0> says 7
<0.251.0> says 6
<0.250.0> says 5
<0.249.0> says 4
<0.248.0> says 3
<0.247.0> says 2
<0.246.0> says 1
109> self() ! hello.
hello
110> self() ! self() ! self() ! hello.
hello
111> eceive X -> io:format("got ~p~n",[X]) end.
* 1:8: syntax error before: X
111> receive X -> io:format("got ~p~n",[X]) end.

User switch command (type h for help)
 --> i

 --> c

** exception exit: killed
112> flush().
ok
113> self() ! self() ! self() ! hello.
hello
114> f().
ok
115> receive X -> io:format("got ~p~n",[X]) end.
got hello
ok
116> receive X -> io:format("got ~p~n",[X]) end.
got hello
ok
117> receive X -> io:format("got ~p~n",[X]) end.
got hello
ok
118> receive X -> io:format("got ~p~n",[X]) end.

User switch command (type h for help)
 --> i

 --> c

** exception exit: killed
119> self() ! self() ! self() ! bye.  
bye
120> flush().
Shell got bye
Shell got bye
Shell got bye
ok
121> c(counter).
{ok,counter}
122> counter:start().
<0.317.0>
123> Cnt = counter:start().
<0.319.0>
124> Cnt ! val.
Val is 0
val
125> Cnt ! inc.
inc
126> Cnt ! Cnt ! Cnt ! Cnt ! inc.
inc
127> Cnt ! val.
Val is 5
val
128> Cnt ! reset.
reset
129> Cnt ! val.
Val is 0
val
130> Cnt ! stop.
<0.319.0> says bye!
stop
131> Cnt ! stop.
stop
132> Cnt ! stop.
stop
133> Cnt ! val.
val
134> c(icounter).
{ok,icounter}
135> Icnt = icounter:start().
<0.336.0>
136> icounter:inc(Icnt).
true
137> icounter:inc(Icnt).
true
138> icounter:inc(Icnt).
true
139> icounter:inc(Icnt).
true
140> icounter:inc(Icnt).
true
141> icounter:inc(Icnt).
true
142> icounter:val(Icnt).
6
143> icounter:reset(Icnt). 
true
144> icounter:val(Icnt).
0
145> icounter:stop(Icnt).
<0.336.0> says bye!
true
146> icounter:inc(Icnt).
true
147> icounter:val(Icnt).

User switch command (type h for help)
 --> i

 --> c

** exception exit: killed
148> c(alarm).
{ok,alarm}
149> alarm:start(10000,wake_up).
<0.356.0>
150> receive A -> A end.
wake_up
151> self() ! {good,goal}.
{good,goal}
152> self() ! {good,win}. 
{good,win}
153> self() ! {bad,loose}.
{bad,loose}
154> self() ! {good,baby_born}.
{good,baby_born}
155> alarm:priority_rec().
loose
156> alarm:priority_rec().
goal
157> alarm:priority_rec().
win
158> alarm:priority_rec().
baby_born
159> alarm:priority_rec().

User switch command (type h for help)
 --> i

 --> c

** exception exit: killed
160> halt().
(base) ex-apc3:erl 2023 bruni$ 
