Permalink
Browse files

erlang

  • Loading branch information...
1 parent 8768617 commit 9e7d5d2e14d8f796352ae94300e861cde9e36a40 @kscaldef kscaldef committed Aug 15, 2009
Showing with 25 additions and 0 deletions.
  1. +1 −0 bin/compare_implementations.pl
  2. +1 −0 bin/compare_problem_number.pl
  3. +17 −0 erlang/001/01.erl
  4. +6 −0 erlang/001/02.erl
@@ -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;
@@ -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;
View
@@ -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).
+
+
View
@@ -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.