Erlang Online IDE & Code Editor for Technical Interviews
Running Erlang/OTP 24 - IntelliSense is not available
You should define the module as “solution” and define and export a method named “start” on it, like so:
-module(solution).
-export([start/0]).
start() ->
io:format("Hello, World").
Code language: Erlang (erlang)
If you’d like to write some tests using eunit
, you can do so as long as you remember to include_lib
and invoke your module’s test
function from your start
function:
-module(solution).
-export([start/0]).
-include_lib("eunit/include/eunit.hrl"). % attach eunit handlers to this module
f(0) -> 1;
f(1) -> 1;
f(N) when N > 1 -> f(N-1) + f(N-2).
f_test() ->
1 = f(0),
1 = f(1),
2 = f(2),
3 = f(3),
6 = f(4). % this should fail
start() ->
test(). % remember to call test from start, or we won't know that we need to run tests!
Code language: Erlang (erlang)