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

dpflan Group Title

Can someone explain anonymous functions?

  • 3 years ago
  • 3 years ago

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

    I don't intend this to sound snippy, but an anonymous function is a function that has no name. Here's a normal function to multiply its parameter by two: def MulByTwo(x): return x * 2 But Python, like some other languages, lets you define such a function for use without having to create a name for it, and avoid cluttering the namespace with names that you don't really need. In such a case, you create the same function with "lambda x: x * 2". So why would you want to do that? In so-called functional programming, you often want to pass a function as a parameter to another function. This lets you do that without creating a name that will never be used explicitly.

    • 3 years ago
  2. dpflan Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    thanks, so in passing a function as a parameter, i'm not passing the result, but simply a function/process to manipulate data/variables in another function?

    • 3 years ago
  3. Radly Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    That's the general idea. I don't use it much; for a complete explanation, see http://docs.python.org/howto/functional.html.

    • 3 years ago
  4. dpflan Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Thanks

    • 3 years 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.