Skip to content

Instantly share code, notes, and snippets.

@MrJaba
Created January 31, 2011 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrJaba/803836 to your computer and use it in GitHub Desktop.
Save MrJaba/803836 to your computer and use it in GitHub Desktop.
Erlang Day 1 Exercises
-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