3 ms·
If 0 and a function that always returns 0 are the same thing, does that make `lambda: lambda: 0` also the same? I suppose it must do, otherwise `0` and `lambda:
by jstanley 7mo ago
If 0 and a function that always returns 0 are the same thing, does that make `lambda: lambda: 0` also the same? I suppose it must do, otherwise `0` and `lambda: 0` were not truly the same.
- fn-mote 7mo agoAnother way to make the point: when you write 0, which do you mean? In a pure language like Haskell, 0-ary functions <==> constants
- tikhonj 7mo agoIn a non-strict language without side-effects, having a function with no arguments does not make sense. Haskell doesn't even let you do that. You can write a function that takes a single throw-away argument (eg 0 vs \ () -> 0) and, while the two have some slight differences at runtime, they're so close in practice that you almost never write functions taking a () argument in Haskell. (Which is very different from OCaml!)
- ssivark 7mo agoYes, and that becomes more intuitive when you "un-curry" the nested lambdas into a single lamba with twice the number of arguments. The point is that the state of a constant does not depend whatsoever on the state of the (rest of the) world, how much ever of that state piles on.