Created
April 5, 2017 11:29
-
-
Save iain17/03594558059da5f361bef4f837827177 to your computer and use it in GitHub Desktop.
Write a function that uses recursion to count to ten.
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
-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