Skip to content

Instantly share code, notes, and snippets.

@iain17 iain17/count.erl
Created Apr 5, 2017

Embed
What would you like to do?
Write a function that uses recursion to count to ten.
-module(count).
-export([to_ten/0]).
%Assignment: Write a function that uses recursion to count to ten.
%Entrypoint
to_ten() -> count(0).
% Base case
count(10) -> 10;
%keep on adding 1 untill you reach the above function
count(Value) -> count(Value + 1).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.