1

I have been taught in my Bsc course that in functional programming even numbers are functions that return themselves. I've read that lambda calculus consists only of functions and nothing else, so that would make sense. However, I didn't find any articles about functional programming that introduced numbers as functions. However(!), I also read that expressions in functional programming are functions and numbers are considered expressions, thus numbers must be functions...right?

In short, I am very confused about what is and isn't a function in functional programming.

5
  • 2
    If numbers were functions that return themselves, that would mean that returned value is also a function. That’s rather recursive. Somewhere there’s gotta be an actual numeric value involved.
    – deceze
    Commented Oct 9, 2023 at 20:15
  • 1
    No, in actual functional programming, numbers are numbers and functions are functions. Implementations may represent expressions as functions, but that is irrelevant, and those functions would certainly not return themselves. The lambda calculus doesn't have numbers, but you can encode numbers in it however you like. the Church Numerals are the standard way. Commented Oct 10, 2023 at 13:50
  • Church numerals are used in some of the lambda calculus-based proof assistants and in dependent type systems, but there is no good reason to use them in more generic use cases.
    – SK-logic
    Commented Oct 14, 2023 at 13:53
  • nice blog post debunking this: conal.net/blog/posts/everything-is-a-function-in-haskell
    – mb21
    Commented Oct 16, 2023 at 7:14
  • What's actually true in functional languages is "everything is an expression, there are no statements".
    – mb21
    Commented Oct 16, 2023 at 7:21

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.