GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - mneri/lambda: Lambda Calculus Standard Functions in Java

BranchesTags
Open more actions menu

Latest commit

 

History

69 Commits
69 Commits

Folders and files

NameName
Last commit message
Last commit date
gradle/wrapper
gradle/wrapper
 
 
src
src
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

lambda

lambda is a really tiny library that brings lambda calculus in Java.

Build Status Codacy Badge Language grade: Java Total alerts Coverage Status

Introduction

One of the goals of the project is to make Java look like lambda calculus as much as possible. The identity function I, for example, is pretty close.

λ I = (λ x) -> x;

β-reductions are introduced by the word β; for example, the AND function becomes

λ AND = (λ a) -> (λ b) -> β(a, b, a);

Performances

Long story short, it sucks, but it has never been the goal.

Function Library

The library contains a good number of λ-expressions. For example, three different fixed-point combinators (X, Y, and Θ).

λ X = (λ f) -> β((λ x) -> β(x, x), (λ x) -> β(f, β(x, x)));
λ Y = (λ f) -> β((λ x) -> β(f, β(x, x)), (λ x) -> β(f, β(x, x)));
λ Θ = β((λ x) -> (λ y) -> β(y, β(x, x, y)), (λ x) -> (λ y) -> β(y, β(x, x, y)));

Church encoding for numbers through 16 and powers of two through 1024 have been implemented.

λ ZERO  = (λ f) -> (λ x) -> x;
λ ONE   = β(SUCC, ZERO);
λ TWO   = β(SUCC, ONE);
// ...
λ ONETHOUSANDTWENTYFOUR = β(EXP, TWO, TEN);

Standard high-order functions such as FILTER, MAP, FOLDL and FOLDR.

Examples

λ FACT = β(Y, (λ f) -> (λ n) -> β(IF, β(LEQ, n, ONE),
                                      ONE,
                                      β(MUL, n, β(f, β(PRED, n)))));
λ FIB = β(Y, (λ f) -> (λ n) -> β(IF, β(LEQ, n, TWO),
                                     ONE,
                                     β(ADD, β(f, β(PRED, n)), β(f, β(SUB, n, TWO)))));
λ COLLATZ = β(Y, (λ f) -> (λ n) -> β(IF, β(EQ, n, ONE),
                                         β(CONS, ONE, NIL),
                                         β(CONS, n, β(f, β(IF, β(ISEVEN, n),
                                                               β(DIV, n, TWO),
                                                               β(SUCC, β(MUL, n, THREE)))))));
λ SORT = β(Y, (λ f) -> (λ l) -> β(IF, β(ISNIL, l),
                                      NIL,
                                      β(CAT, β(CAT, β(f, β(FILTER, β(FLIP, LEQ, β(HEAD, l)), β(TAIL, l))),
                                                         β(CONS, β(HEAD, l), NIL)),
                                             β(f, β(FILTER, β(FLIP, GREAT, β(HEAD, l)), β(TAIL, l))))));

About

Lambda Calculus Standard Functions in Java

Topics

lambda-calculus

Resources

Readme
GPL-3.0 license
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.