-
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
ashwini mane new pull #26
base: master
Are you sure you want to change the base?
ashwini mane new pull #26
Conversation
Smu id 46990558 Ashwini Mane
ashwini mane-46990558
please ignore my very first submission |
# Write a function that adds two numbers using fn syntax # | ||
########################################################## | ||
|
||
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
# Write a function that adds two numbers using & syntax # | ||
########################################################## | ||
|
||
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
# no explicit + operators in your function # | ||
##################################################################### | ||
|
||
sum3a = fn (a,b,c) -> sum2a.(sum2a.(a,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
# Do the same using the & notation # | ||
#################################### | ||
|
||
sum3b = &(sum2b.(&1,&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
# function. The examples below will make this clearer :) # | ||
######################################################################## | ||
|
||
create_adder = fn n -> (fn n1 -> n + n1 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(list1,list2) do |
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.
2
Interesting approach, but pretty convoluted.
If you recurse, you don't need to check the lengths of the list.
and
if acc == 0 do false
else
true
end
is pretty horrible, both as code and in layout.
Here's another way of doing it:
def list_equal([], []), do: true
def list_equal([head|tail], [head|tail]), do: true
def list_equal([head|_], [head2|_]), do: false
""" | ||
|
||
|
||
def won(tuple) do |
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
So close.
But, instead of
{:x, _ ,_, :x,_,_, :x,_,_} -> :x
and
{:o, _ ,_, :o,_,_, :o,_,_} -> :o
You could have had
{ m, _, _, m, _, _, m, _, _ } -> m
|
||
#def min . . . "your code" | ||
|
||
def min(list) do |
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
return value will be the thing you have to manipulate. | ||
""" | ||
#My even_odd code | ||
def even_odd(list) do |
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.
8
Two things. First, the random indentation makes this really hard to read.
Second, it is really crying out to be two functions.
(and you used Enum.reduce again...)
####################### | ||
#My reverse code | ||
####################### | ||
def reverse(list), |
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.
3
Why did you reimplement reduce, and then not use it?
In theory, this should be 0, but I'm giving you the benefit of the doubt.
Smu id 46990558
Ashwini Mane