
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
λ-calculus is the simplest functional programming language.
In λ-calculus, "function" means "abstraction from something". For example, instead of 2 + 1
, you can write \X. X + 1
, and then substitute an arbitrary object for X
.
This concept of "function" (or, more correctly, "abstraction") is so fundamental, every programming language implements it more or less explicitely, as it's necessary to avoid code duplication and allow code reuse. So, in some sense, λ-calculus directly follows from DRY itself.
At the same time, you can express any computation or idea by solely using "functions". This is the only mechanism λ-calculus relies on. No built-in numbers or strings, no control flow statements.
So, "abstraction from something" is not only necessary, but it's also sufficient. This is what makes λ-calculus so important and beautiful.
To install λ-lang you can use this command in your terminal:
python3 -m pip install lmdlang
To run your λ-program:
lmdlang code.lambda
To run your λ-program you can use this command in your terminal:
python3 -m lmdlang.main code.lambda
poetry build
python3 -m pip install dist/package.whl
lmdlang code.lambda
Then your λ-expression will be fully evaluated and the program will print the result.
This is an example of a λ-program:
three := \f. \x. f (f (f x));
square := \num. \f. num (num f);
square three
You can find more examples here: https://en.wikipedia.org/wiki/Church_encoding
In general, a λ-program consists of several definitions followed by a main expression that is the target for evaluation.
In fact, definitions (:=) are just syntactic sugar over λ-expressions, and they are not required at all. Their main purpose is to simplify the beginner experience.
So, the real basis of λ-calculus is λ-expression.
And you're probably already familliar with it.
Take a look at this example:
\f. \x. f (f (f x))
It can be roughly translated into Python like this:
lambda f: lambda x: f(f(f(x)))
f x y z
can be interpreted as f(x, y, z)
.
But actually it is f(x)(y)(z)
, since this is how argument passing works in λ-calculus. We don't need the concept of multiple arguments.
So, we only use:
\argument_name. body_term
)variable_name
)applied_term argument_term
)And that gives us a Turing-complete language.
λ-calculus also supports unusual evaluation order.
For example, if you type (\x. \y. y) (...)
, the contents of (...)
never matter or being touched. It's like an "if" statement with condition being false.
Thus, only the necessary calculations occur, allowing us to work with infinite constructions that in other languages like Python would result in an endless loop.
FAQs
The simplest functional programming language
We found that lmdlang demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.