Git Product home page Git Product logo

lisa's Introduction

lisa

LISt Action

build / install

are you on linux? make will probably work. otherwise, see Makefile for the suggested compiler flags.

usage

#f = () = 0

scheme lisa
(begin a b c) (, a b c)
(lambda - #f) (\)
(lambda - a) (\ a)
(lambda (a) b) (\ a b)
(lambda (a b) c) (\ a b c)
(lambda (a . b) c) (\ a b . c)
(begin (define a b) a) (: a b)
(begin (define a b) c) (: a b c)
(cond (a b) (#t #f)) (? a b)
(cond (a b) (#t c)) (? a b c)
(cond (a b) (c d) (#t #f)) (? a b c d)

etc.

. is a normal symbol with special meaning in \. atoms in tail position are not shown.

some useful functions:

  • + - * / % & | ^ ~ << >> < <= = >= >
  • X A B ~ cons car cdr
  • sym ~ gensym
  • . show args then newline, return last arg or 0
  • functions for strings & hash tables are not stable
  • other functions defined in lib

examples

a quine

((\ - (L - (L ` -))) '(\ - (L - (L ` -))))

church numerals

(:
 ; zero is the constant function at the identity function
 zero (\ (\ - -))
 ; a successor applies its argument then yields to its predecessor
 (((succ f) g) h) ((f g) (g h))

 one (succ zero) ; \ f -> f = identity
 two (succ one) ; \ f -> f . f = square
 three (succ two) ; \ f -> f . f . f = cube 

 ; binary operations follow from succ:
 ((add g) f)         ; the monoid on N
  ((f succ) g)       ; \ g f x -> f x . g x = liftA2 (.)
 ((mul g) f)         ; the monoid on End(N)
  ((f (add g)) zero) ; \ g f x -> f (g x) = (.)

 ; the rest are iterations of the "up arrow" map
 (((up op) g) f) ((f (op g)) one)
 pow (up mul) ; exponentiation ; \ f -> f = id = one
 tet (up pow) ; tetration, etc.

 (C n) (? n (succ (C (- n 1))) zero) ; fixnum -> N
 (N c) ((c (\ x (+ x 1))) 0))        ; N -> fixnum

fizzbuzz

(: (/p m n) (~ (% m n))
   (fizzbuzz m)
    ((\ (+ m 1)) (. (?
     (/p m 15) 'fizzbuzz
     (/p m 5)  'buzz
     (/p m 3)  'fizz
     m)))
 ((((pow ((mul ((add three) two)) two)) two) fizzbuzz) 1))

lisa's People

Contributors

cofinalsubnets avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

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.