Created
January 31, 2011 09:50
-
-
Save MrJaba/803836 to your computer and use it in GitHub Desktop.
Erlang Day 1 Exercises
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(counter). | |
-export([count/1]). | |
-export([str_count/2]). | |
%count to 10 recursively | |
count(10) -> 10; | |
count(N) -> count(N+1). | |
%count the words in a string recursively | |
str_count([],N) -> N; | |
str_count([Head|Rest],N) -> if | |
Head == 32 -> | |
str_count(Rest, N+1); | |
true -> | |
str_count(Rest, N) | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment