-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assignment2 #30
base: master
Are you sure you want to change the base?
Assignment2 #30
Conversation
5 minutes late. I'll grade this, but… |
sum2a = your_anonymous_function(1, 2) | ||
#sum2a = your_anonymous_function(1, 2) | ||
|
||
sum2a = fn(a, b) -> a + b end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5
sum2b = your_anonymous_function(1, 2) | ||
#sum2b = your_anonymous_function(1, 2) | ||
|
||
sum2b = &(&1 + &2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5
sum3a = your_anonymous_function(1, 2, 3) | ||
#sum3a = your_anonymous_function(1, 2, 3) | ||
|
||
sum3a = fn(a, b, c) -> sum2a.(a, sum2a.(b,c)) end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5
sum3b = your_anonymous_function | ||
#sum3b = your_anonymous_function | ||
|
||
sum3b = &(sum2b.(&1, sum2b.(&2, &3))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5
create_adder = your_anonymous_function(1) | ||
#create_adder = your_anonymous_function(1) | ||
|
||
create_adder = fn(x) -> (fn(y) -> x + y end) end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10
|
||
#def list_equal . . . "your code" | ||
|
||
def list_equal([],[]) do true end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4
Same comment here. On line 130, you could test the two heads are equal with
def list_equal([h|t1], [h|t2]), do: list_equal(t1, t2)
def list_equal(_, _), do: false
@@ -149,7 +180,43 @@ defmodule Ex03 do | |||
Think a little about a nice way to lay this code out. | |||
""" | |||
|
|||
def won . . . "your code" | |||
#def won . . . "your code" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0
You were on the right track. Here's my solution:
def won(position) do
case position do
{ a, a, a,
_, _, _,
_, _, _ } -> a
{ _, _, _,
a, a, a,
_, _, _ } -> a
{ _, _, _,
_, _, _,
a, a, a } -> a
{ a, _, _,
a, _, _,
a, _, _ } -> a
{ _, a, _,
_, a, _,
_, a, _ } -> a
{ _, _, a,
_, _, a,
_, _, a } -> a
{ a, _, _,
_, a, _,
_, _, a } -> a
{ _, _, a,
_, a, _,
a, _, _ } -> a
_ -> false
end
end
def reverse . . . "your code" | ||
#def reverse . . . "your code" | ||
|
||
def reverse(list), do: reduce(list, [], &[&1 | &2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5
def min . . . "your code" | ||
#def min . . . "your code" | ||
|
||
def min(list), do: reduce(list, &(if &1 < &2 do &1 else &2 end)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5
def even_odd . . . "your code" | ||
|
||
|
||
#def even_odd . . . "your code" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cary Humphries
47237948