Skip to content
This repository has been archived by the owner on Oct 25, 2019. It is now read-only.

Commit

Permalink
erlang
Browse files Browse the repository at this point in the history
  • Loading branch information
kscaldef committed Aug 15, 2009
1 parent 8768617 commit 9e7d5d2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions bin/compare_implementations.pl
Expand Up @@ -13,6 +13,7 @@
# we should change perl6 to rakudo
perl6 => $ENV{PERL6} || catfile( $ENV{HOME},qw{git rakudo perl6}),
ruby => $ENV{RUBY} || 'ruby',
erlang => $ENV{ERLANG} || 'escript',
);

my ($profile_lang,$euler_problem,$count) = @ARGV;
Expand Down
1 change: 1 addition & 0 deletions bin/compare_problem_number.pl
Expand Up @@ -13,6 +13,7 @@
# we should change perl6 to rakudo
perl6 => $ENV{RAKUDO} || $ENV{PERL6} || catfile( $ENV{HOME},qw{git rakudo perl6}),
ruby => $ENV{RUBY} || 'ruby',
erlang => $ENV{ERLANG} || 'escript',
);
my @languages = keys %interp;

Expand Down
17 changes: 17 additions & 0 deletions erlang/001/01.erl
@@ -0,0 +1,17 @@
#!/usr/bin/env escript

main(_) ->
Sum = do_sum(0, 0),
io:format("~p~n", [Sum]).

do_sum(1000, Acc) -> Acc;
do_sum(N, Acc) ->
NewAcc =
case N of
M when M rem 3 == 0 -> Acc + N;
M when M rem 5 == 0 -> Acc + N;
_ -> Acc
end,
do_sum(N+1, NewAcc).


6 changes: 6 additions & 0 deletions erlang/001/02.erl
@@ -0,0 +1,6 @@
#!/usr/bin/env escript

main(_) ->
Sum = lists:sum([ X || X <- lists:seq(1,999),
X rem 3 == 0 orelse X rem 5 == 0]),
io:format("~p~n", [Sum]).

0 comments on commit 9e7d5d2

Please sign in to comment.