Skip to content

Commit

Permalink
Merge pull request seven1m#18 from jduan/jduan/pattern_match_whole_list
Browse files Browse the repository at this point in the history
Pattern match the whole list
  • Loading branch information
seven1m committed Aug 3, 2015
2 parents 07974c8 + 06715ca commit 33029ed
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 07-fibonacci.exs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ defmodule Fib2 do

def fib2(acc, 0), do: Enum.reverse(acc)

def fib2([first, second | tail], n) do
fib2([first + second] ++ [first, second] ++ tail, n - 1)
def fib2([first, second | _] = lst, n) do
fib2([first + second | lst], n - 1)
end
end

Expand Down

0 comments on commit 33029ed

Please sign in to comment.