Code Monkey home page Code Monkey logo

stdlambda's Introduction

stdlambda—Standard Library for Lamdba Calculus

Lambda Calculus is an inspiring idea, but most of the resources about it list just a couple of utilities and ways to encode data, without getting deep enough into building a practical set of primitives. stdlambda tries to do just that: provide a more or less practical set of primitives for programming in Lambda Calculus. Included are:

  • Frequent combinators like S, K, I, and Y.
  • Church Booleans and all the possible logical operations on them.
  • Church Numerals and arithmetics on them.
    • List-encoded numerals might be provided in the future.
  • Church Pairs (with an opinionated nil = false) and Haskell/Lisp-inspired utilities on them.
    • nil = λx.true pairs might be provided in the future.

Sources of inspiration and code:

Getting Started

  • Feed the definitions from provided files into your Lambda Calculus interpreter. The files (and their interdependencies) are:
    combinators.lambda
    Logical/stack combinators, no deps.
    bool.lambda
    Boolean ops, no deps.
    numbers.lambda
    Numeric, arithmetics. Depends on combinators.lambda and bool.lambda.
    cons.lambda
    Conses. Depends on bool.lambda.
    list.lambda
    Linked lists and utils for them. Mostly fold operations. Depends on cons.lambda, numbers.lambda and combinators.lambda.
    alist.lambda
    Associative (key-value) lists. Depends on cons.lambda and combinators.lambda.
    stack.lambda
    Operations/combinators from stack languages.
    alias.lambda
    Aliases for all of the above.
  • Run the code using these primitives. Say
fac = Y λr.λn.(if (=0 n) 1 (× n (r (1- n))))
(fac 5)

Format

The format is the single-letter single-argument lambdas. The approximate regex would be:

.* = (λ[a-z].)*.*

Not all function applications are enclosed into parentheses and not all applications are single-argument. Example:

first = compose car (0 cdr)

and not

first = ((compose car) (0 cdr))

It’s too much work to maintain such a code. I might reconsider that in the future, though.

stdlambda's People

Contributors

aartaka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

stdlambda's Issues

Haskell `Data.List` functions.

  • last + init
  • foldl?
  • scan
  • Better repeat?
  • take, drop, splitAt
  • span, break
  • isPrefixOf, isSuffixOf, isInfixOf, isSubsequenceOf
  • Proper find with predicates?

Set operations

#2 and #3 instead?

  • lset<=
  • lset=
  • lset-adjoin
  • lset-union
  • lset-intersection
  • lset-difference
  • lset-xor
  • lset-diff+intersection
  • lset-union!
  • lset-intersection!
  • lset-difference!
  • lset-xor!
  • lset-diff+intersection!

String support

Strings are just lists with numbers, though. So having #2 and #3 should be enough to manage strings.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.