Ad
  • Custom User Avatar

    so functions in python are first-class objects -- you're able to set variables equal to them just as with any other object type. lambda is a way to define a function without a name and in this case, the unnamed function takes one argument, n, and we return the expected series. So generateIntegers is now a variable that is equal to the function and generateIntegers(6) would yield the expected value as a consequence of that.

    Apologies for the slightly roundabout description but I think I've avoided writing a spoiler, maybe, mostly..

    I'm using this language feature in an admittedly gimmicky way (to write one-line solutions to codewars problems) but it is a very helpful language feature (the first-classness of functions) -- many other languages treat functions as different (and don't allow this sort of assignment.)

  • Default User Avatar

    how do you run this exactly or input the value n in the function? thanks!