Created
April 11, 2014 22:09
-
-
Save robbielynch/10505586 to your computer and use it in GitHub Desktop.
Demonstration of creating modules inside of IErlang for IPython...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:1449476fef8f91ca592601643d503a97a3dbf7e6c43570c93d7ebf229b1a24d1" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"#IErlang Notebook\n", | |
">Robbie Lynch\n", | |
"\n", | |
">Supervised by Paul Barry\n", | |
"\n", | |
">*Institute of Technology, Carlow, Ireland*" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"#Great News!\n", | |
"##We can now create erlang modules" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"-module(super_awesome_module).\n", | |
"-export([my_favorite_numbers/0, unlucky_number/0]).\n", | |
"\n", | |
"my_favorite_numbers()->\n", | |
"[1, 2, 3, 4, 5].\n", | |
"\n", | |
"unlucky_number()->\n", | |
"((278346287 * 98324928374) - (829437 * 3476) - (27368378729560724309 + (2 * 2)))." | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": [ | |
"[83,117,99,99,101,115,115,102,117,108,108,121,32,67,111,109,112,105,108,101,100]" | |
], | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 1 | |
} | |
], | |
"prompt_number": 1 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"##Then we can make a call to the modules functions" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"super_awesome_module:my_favorite_numbers()." | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": [ | |
"[1,2,3,4,5]" | |
], | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 2 | |
} | |
], | |
"prompt_number": 2 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"super_awesome_module:unlucky_number()." | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": [ | |
"13" | |
], | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 3 | |
} | |
], | |
"prompt_number": 3 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"##And we can still execute erlang expressions" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"lists:sort([8475,34,4565,34,2,99,1,54])." | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": [ | |
"[1,2,34,34,54,99,4565,8475]" | |
], | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 4 | |
} | |
], | |
"prompt_number": 4 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"hello." | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": [ | |
"hello" | |
], | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 5 | |
} | |
], | |
"prompt_number": 5 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"\"Awesome!!\"." | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": [ | |
"[65,119,101,115,111,109,101,33,33]" | |
], | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 6 | |
} | |
], | |
"prompt_number": 6 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [] | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment