Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

aschey

After listening to lecture 9, I'm still confused about the merge and sort functions, particularly the lambda function (here's the code: http://codepad.org/cutcMoyR). On line 39, what is "float.__lt__" and how does it interact with the lambda function? Also, when it's changed to "gt" for "greater than" instead, it sorts in reverse order. How does that work? Thanks!

  • one year ago
  • one year ago

  • This Question is Closed
  1. aschey
    Best Response
    You've already chosen the best response.
    Medals 0

    Oops, the url got messed up. It's http://codepad.org/cutcMoyR . Sorry about that.

    • one year ago
  2. rsmith6559
    Best Response
    You've already chosen the best response.
    Medals 1

    When you define a function, you can give the last argument[s] default values. This allows the function to be called with fewer arguments than the prototype calls for. In this case, if you called sort( L ), it would work using the lambda function for comparison. sort() is acutally being passed the __lt__ method from the Float class to do the comparisons, overriding the lambda, so they don't interact. It's an either or thing.

    • one year ago
  3. aschey
    Best Response
    You've already chosen the best response.
    Medals 0

    Oh okay, that makes sense. Thanks!

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.