erl
launches a shell, which is a vm, which is a node
- Control+\
halt()
% Begin with a percent
% Continue to the end of the line
% There are no multiline comments
init:stop()
cd().
ls().
pwd().
c("some file name.erl").
The format is namespace:functionName(args).
io:fwrite("hello, world\n").
- start with an ->
- end with a .
- statements are seperated by a ,
- statements with multiple clauses seperate them with a ;
- statements with multiple clauses do not put anything after the last clause
f().
Is this what they call naked banging?
- code is loaded from the codepath, .erl files in the cd of the repl will be found automatically
- can be done by entering the following: module:exportedFunctionName().
nodes().
- remote pricedure call, run something on a remote node
- will start a new processs, optionally on a remote node
- Erlang processes are isolated
[X || X <- lists:seq(1,10)].
produces [1,2,3,4,5,6,7,8,9,10]
[X*2 || X <- lists:seq(1,10)].
produces [1,2,3,4,5,6,7,8,9,10]
http://erlang.org/doc/man/erl.html
From the terminal:
erl -sname someNodeName
- this will launch a node with a repl and will report it's 'name' as someNodeName@hostname
nodes().
- will probably return an empty list
- []
net_adm:ping(nodeName@hostName).
- should respond with pong
- if there are special characters in the name you'll need to warp it in ticks, tech. the problem is that this isn't a valid atom name net_adm:ping('dog@host').
- might have a problem connecting from sublime because it doesn't have a name
- fixed this by updating /Users/username/Library/Application Support/Sublime Text 2/Packages/SublimeREPL/config/Erlang/Main.sublime-menu
nl(modulename).
#Start a module on a remote node spawn('nodeName@hostname', module, function, args). e.g. spawn('dog@salad', atm, stop, []).
- will return the erlang pid of the process
[spawn(X, atm, stop, []) || X <- nodes()].
[spawn(X, atm, stop, []) || X <- nodes()++[node()]].
lrrad