Search code examples
lambda-calculus

Practical usage of lambda calculus


I have recently started self learning lambda calculus. One thing i am unable to visualize is how this language can be used to build practical applications. One simple use case i could think of is the following : Assume we have records of test scores of multiple students in a class. Like

name = John, math=30, science = 40 , english = 60 
name = Jane, math=22, science = 80, english = 45
name = Mark, math=77, science = 43, english = 83

How can we write a program in lambda calculus (untyped or simply typed) that computes the average of test scores for each student.Please note that my question is not about the parsing of above text, but about the actual core computation .

Expected output:

name = John, average = 43
name = Jane, average = 49
name = Mark, average = 68

Can you please kindly share how this simple computation can be implemented using lambda calculus?

Even though i only have little knowledge of Haskell, I am not looking for haskell implementations, but i am curios about how this would be done in lambda-calculus itself.

Best Regards.


Solution

  • Even though lambda expressions are used in lots of programming languages like JavaScript and C# (and of course all functional languages), pure lambda calculus (and I assume this is what you refer to) is not meant to be used in practice. Just like Turing Machines are not meant to be for any practical applications.

    The purpose of the lambda calculus is to model and reason about the nature of computation. This includes foundational questions like computability, equivalences, and encodings.

    So, while it would be possible to write a lambda calculus expression that does what you are asking for, this expression would be huge and in itself it wouldn't be particularly enlightening. The interesting bit is what the basic building blocks of such an expression would look like: how do you encode booleans, boolean operators, conditional branches, integers, arithmetic operations, lists and list operations - and finally, recursion - in pure lambda calculus? Once you know the answer to these questions, you could in principle build the expression that you are asking for.