Developed by Robbie Lynch
Supervised by Paul Barry
Institute of Technology, Carlow, Ireland.
Download the IErlang Kernel for IPython at http://github.com/robbielynch/ierlang
AnInt = 1234.
1234
AFloat = 55 / 3.
18.333333333333332
AString = "Awesome!".
"Awesome!"
AnAtom = 'This is an atom with spaces'.
'This is an atom with spaces'
atom_with_no_spaces.
atom_with_no_spaces
{this, is, a, tuple_of_atoms}.
{this,is,a,tuple_of_atoms}
AList = [1,2,3,4,5].
[1,2,3,4,5]
i.e. Referring to previously assigned variables.
AVariable = 100.
100
AnotherVar = 77.
77
AVariable + AnotherVar.
177
NedStark = [[]|[AnotherVar + AVariable]].
[[],177]
NedStark.
[[],177]
lists:sort([10,9,8,3,5,4,6,1,7,2]).
[1,2,3,4,5,6,7,8,9,10]
io:format("hello").
ok
is_integer(4325345).
true
os:cmd("pwd").
"/home/robbie/dev/ierlang/src
"
is_binary(<<"Hello">>).
true
9283479238472398472398472394872398 * 28347632847623847623847623847623847623847632874623864.
263164661000754185502995313263072243291280523500406936157710040110469708162166525705872
99 div 5. %%Integer division
19
99 / 5.
19.8
893475 - 98234798432579348753.
-98234798432578455278
this will throw an error
{badmatch,{error,{1,erl_parse,["syntax error before: ","will"]}}}
lists:flatten(notalist).
function_clause
55 div 44.3.
badarith
To make interacion with the terminal quicker and easier, you can run terminal commands
by pre-pending ;;
before the command. For example:
;;pwd
"/home/robbie/dev/ierlang/src
"
;;date
"Sun Apr 20 16:56:04 BST 2014
"
;;whereis ipython
"ipython: /usr/bin/ipython2.7 /usr/bin/X11/ipython2.7 /usr/local/bin/ipython /usr/share/man/man1/ipython.1.gz
"
;;ping -c 5 google.com
"PING google.com (74.125.24.101) 56(84) bytes of data.
64 bytes from de-in-f101.1e100.net (74.125.24.101): icmp_req=1 ttl=44 time=60.0 ms
64 bytes from de-in-f101.1e100.net (74.125.24.101): icmp_req=2 ttl=44 time=68.5 ms
64 bytes from de-in-f101.1e100.net (74.125.24.101): icmp_req=3 ttl=44 time=47.4 ms
64 bytes from de-in-f101.1e100.net (74.125.24.101): icmp_req=4 ttl=44 time=67.1 ms
64 bytes from de-in-f101.1e100.net (74.125.24.101): icmp_req=5 ttl=44 time=45.8 ms
--- google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4004ms
rtt min/avg/max/mdev = 45.816/57.810/68.506/9.563 ms
"
;;ls mochi*
"mochijson2.beam
mochijson2.erl
mochinum.beam
mochinum.erl
"
;;erlc mochijson2.erl
[]
It's possible to start the original IPython Notebook with the command
;;ipython notebook
Although, it does kill our kernel :(
And if we deliberatly leave an error on line 4... it will tell us....
-module(super_awesome_module). %%First line must begin with -module().
-export([my_favorite_numbers/0, unlucky_number/0]).
my_favorite_numbers()- %%<---------------------This is where the error is%%
[1, 2, 3, 4, 5].
unlucky_number()->
((278346287 * 98324928374) - (829437 * 3476) - (27368378729560724309 + (2 * 2))).
super_awesome_module.erl:4: syntax error before: '-'
super_awesome_module.erl:2: function my_favorite_numbers/0 undefined
It also tells us when things work...
-module(super_awesome_module). %%First line must begin with -module().
-export([my_favorite_numbers/0, unlucky_number/0]).
my_favorite_numbers()->
[1, 2, 3, 4, 5].
unlucky_number()->
((278346287 * 98324928374) - (829437 * 3476) - (27368378729560724309 + (2 * 2))).
Successfully Compiled
We can reference the exported functions from our compiled modules
super_awesome_module:my_favorite_numbers().
[1,2,3,4,5]
lists:reverse(super_awesome_module:my_favorite_numbers()).
[5,4,3,2,1]
super_awesome_module:unlucky_number().
13
MyPid = spawn(super_awesome_module, unlucky_number, []).
<0.49.0>
MyPid.
<0.49.0>