Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

maneashwini
Copy link

Smu id 46990558
Ashwini Mane

Smu id 46990558
Ashwini Mane
ashwini mane-46990558
@maneashwini
Copy link
Author

please ignore my very first submission
In case if u couldn't find refer the attachment

assignment2.zip

# Write a function that adds two numbers using fn syntax #
##########################################################

sum2a = fn (a,b) -> a+b end
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

@pragdave pragdave Sep 21, 2016

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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),
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants