Skip to content

Instantly share code, notes, and snippets.

View Jdtanacredi's full-sized avatar

Justin Jdtanacredi

View GitHub Profile
@Jdtanacredi
Jdtanacredi / MyList.ex
Created February 14, 2016 18:47
Assignments for list recursion
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
@Jdtanacredi
Jdtanacredi / gist:6136794
Created August 2, 2013 01:15
This is a pig latin converter homework assignment I've been working on.
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