aboutsummaryrefslogtreecommitdiff
path: root/step-02
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2024-02-09 21:02:57 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2024-02-09 21:02:57 +0100
commit293916c8f4dc109082ecd709e5e4c19a0847b0cd (patch)
treed0178f9434e0f01b7c5b12850eceee126bc8f946 /step-02
downloaderlang-workshop-293916c8f4dc109082ecd709e5e4c19a0847b0cd.tar.gz
erlang-workshop-293916c8f4dc109082ecd709e5e4c19a0847b0cd.tar.bz2
erlang-workshop-293916c8f4dc109082ecd709e5e4c19a0847b0cd.tar.xz
erlang-workshop-293916c8f4dc109082ecd709e5e4c19a0847b0cd.zip
wip
Diffstat (limited to 'step-02')
-rw-r--r--step-02/README:md26
-rw-r--r--step-02/step02.erl5
2 files changed, 31 insertions, 0 deletions
diff --git a/step-02/README:md b/step-02/README:md
new file mode 100644
index 0000000..4f531be
--- /dev/null
+++ b/step-02/README:md
@@ -0,0 +1,26 @@
+Basic syntax demonstration!
+
+```erlang
+-module(step02).
+-export([double/1]).
+
+double(X) ->
+ 2 * X.
+```
+
+* Statements are terminated with a full stop: ".".
+* `module` declares the name of the module. Should match file name by default.
+* `export` names functions to export out of this module. Will be usable by other modules. The `func/N` syntax means *the function `func`* with *N* arguments.
+* `double(X)` is a function declaration and implementation.
+
+Using this module looks like this:
+
+```
+1> c(step02).
+{ok,step02}
+2> step02:double(4).
+8
+```
+
+* The `c/1` function compiles a module. Notice that it returns ok and a module name.
+* To call the function, the module is explicitly named.
diff --git a/step-02/step02.erl b/step-02/step02.erl
new file mode 100644
index 0000000..fe4b968
--- /dev/null
+++ b/step-02/step02.erl
@@ -0,0 +1,5 @@
+-module(step02).
+-export([double/1]).
+
+double(X) ->
+ 2*X.