This file contains hidden or 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
| defmodule MyList do | |
| def sum([]), do: 0 | |
| def sum([head | tail]), do: head + sum(tail) | |
| def mapsum([],_), do: 0 | |
| def mapsum([head | tail], function) do | |
| function.(head) + mapsum(tail,function) | |
| end | |
| def maxlist([],value), do: value |
This file contains hidden or 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
| def translate pigLatin | |
| # difference between .. & ... again? //CHECKED | |
| alphabet = ('a'..'z').to_a | |
| # easiest method, make array? //CHECKED | |
| vowel = %w[a e i o u] | |
| # %w foo bar / "word array" | |
| consonant = alphabet - vowel | |
| #use if else/if |