
{"id":8182,"date":"2013-02-19T19:51:28","date_gmt":"2013-02-19T19:51:28","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=8182"},"modified":"2013-02-19T19:51:28","modified_gmt":"2013-02-19T19:51:28","slug":"erlang-function","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2013\/02\/19\/erlang-function\/","title":{"rendered":"Hacking with the Erlang Emulator"},"content":{"rendered":"<pre>\nThe  erl program starts an Erlang runtime system. The exact details\n(for example, whether erl is a script or a program and which other\nprograms it calls) are system-dependent.\n\n\n\n\n\ncommandline session\n\n\n$erl\nErlang R15B01 (erts-5.9.1) [source] [64-bit] [async-threads:0] [kernel-poll:false]\n\nEshell V5.9.1 (abort with ^G)\n1&gt; b().\nok\n2&gt; double = fun(value) -&gt; 2*value end.\n** exception error: no match of right hand side value #Fun&lt;erl_eval.6.82930912&gt;\n3&gt; double = fun(value) -&gt; ( 2 * value) end.\n** exception error: no match of right hand side value #Fun&lt;erl_eval.6.82930912&gt;\n4&gt; double = fun(value) -&gt; 2 * value end.\n** exception error: no match of right hand side value #Fun&lt;erl_eval.6.82930912&gt;\n5&gt; Double = fun(value) -&gt; 2 * value end.\n#Fun&lt;erl_eval.6.82930912&gt;\n6&gt; Double(5).\n** exception error: no function clause matching\nerl_eval:'-inside-an-interpreted-fun-'(5)\n7&gt; b().\nDouble =\nfun(value) -&gt;\n2 * value\nend\nok\n8&gt; Double(5).\n** exception error: no function clause matching\nerl_eval:'-inside-an-interpreted-fun-'(5)\n9&gt; Double = fun(Value) -&gt; (2 * Value) end.\n** exception error: no match of right hand side value #Fun&lt;erl_eval.6.82930912&gt;\n10&gt; Double = fun(Value) -&gt; 2 * Value end.\n** exception error: no match of right hand side value #Fun&lt;erl_eval.6.82930912&gt;\n11&gt; Double = fun(Value) -&gt; 2*Value end.\n** exception error: no match of right hand side value #Fun&lt;erl_eval.6.82930912&gt;\n12&gt; Double = fun(Value) -&gt; 2*Value end.\n** exception error: no match of right hand side value #Fun&lt;erl_eval.6.82930912&gt;\n13&gt; Double = fun(value) -&gt; 2*value end.\n#Fun&lt;erl_eval.6.82930912&gt;\n14&gt; b().\nDouble =\nfun(value) -&gt;\n2 * value\nend\nok\n15&gt; Double(5).\n** exception error: no function clause matching\nerl_eval:'-inside-an-interpreted-fun-'(5)\n16&gt; Double(2).\n** exception error: no function clause matching\nerl_eval:'-inside-an-interpreted-fun-'(2)\n17&gt; value = 10\n17&gt; Double(value).\n* 2: syntax error before: Double\n17&gt; Double = fun(value) -&gt; 2 * value end.\n#Fun&lt;erl_eval.6.82930912&gt;\n18&gt; Double(value).\n** exception error: bad argument in an arithmetic expression\nin operator *\/2\ncalled as 2 * value\n19&gt; Double = fun(value) -&gt; 2 + value end.\n** exception error: no match of right hand side value #Fun&lt;erl_eval.6.82930912&gt;\n20&gt; Double = fun(value) -&gt; 2+value end.\n** exception error: no match of right hand side value #Fun&lt;erl_eval.6.82930912&gt;\n21&gt; Double = fun(value) -&gt; (2 + value) end.\n** exception error: no match of right hand side value #Fun&lt;erl_eval.6.82930912&gt;\n22&gt; Double = fun(value) -&gt; value end.\n** exception error: no match of right hand side value #Fun&lt;erl_eval.6.82930912&gt;\n23&gt; Double = fun(value) -&gt; value+1 end.\n** exception error: no match of right hand side value #Fun&lt;erl_eval.6.82930912&gt;\n24&gt; Double1 = fun(value) -&gt; value+1 end.\n#Fun&lt;erl_eval.6.82930912&gt;\n25&gt; Double1(value).\n** exception error: bad argument in an arithmetic expression\nin operator +\/2\ncalled as value + 1\n26&gt; Double1(3).\n** exception error: no function clause matching\nerl_eval:'-inside-an-interpreted-fun-'(3)\n27&gt; summer = fun(Val) -&gt; Val + 1 end.\n** exception error: no match of right hand side value #Fun&lt;erl_eval.6.82930912&gt;\n28&gt; Summer = fun(Val) -&gt; Val + 1 end.\n#Fun&lt;erl_eval.6.82930912&gt;\n29&gt; Summer(2).\n3\n30&gt;\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The erl program starts an Erlang runtime system. The exact details (for example, whether erl is a script or a program and which other programs it calls) are system-dependent. commandline session $erl Erlang R15B01 (erts-5.9.1) [source] [64-bit] [async-threads:0] [kernel-poll:false] Eshell V5.9.1 (abort with ^G) 1&gt; b(). ok 2&gt; double = fun(value) -&gt; 2*value end. ** &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2013\/02\/19\/erlang-function\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Hacking with the Erlang Emulator&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[149,91],"tags":[709,728,1437],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/8182"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=8182"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/8182\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=8182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=8182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=8182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}