Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
what the fuck is a lambda
 
#2
it defines a basic anonymous function (called a lambda function), useful for when you ever need to return a function like this:
############################################
def createAdder():
    return lambda a1, a2 : a1 + a2 # a1 and a2 are the arguments

adder = createAdder() # returns the lambda function
print( adder(5,5) ) # --> 10
############################################
it does look a little similar to the c ternary but is completely different
Reply


Messages In This Thread
what the fuck is a lambda - by kwabockle - 06-19-2025, 11:11 PM
RE: what the fuck is a lambda - by queue - 06-19-2025, 11:21 PM
RE: what the fuck is a lambda - by kwabockle - 06-19-2025, 11:25 PM
RE: what the fuck is a lambda - by queue - 06-19-2025, 11:29 PM
RE: what the fuck is a lambda - by kwabockle - 06-19-2025, 11:35 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)