项目作者: gw000

项目描述 :
high density lisp machine
高级语言: C
项目地址: git://github.com/gw000/lips.git
创建时间: 2021-03-02T10:45:30Z
项目社区:https://github.com/gw000/lips

开源协议:The Unlicense

下载


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

  1. ((\ - (L - (L ` -))) '(\ - (L - (L ` -))))

church numerals

  1. (:
  2. ; zero is the constant function at the identity function
  3. zero (\ (\ - -))
  4. ; a successor applies its argument then yields to its predecessor
  5. (((succ f) g) h) ((f g) (g h))
  6. one (succ zero) ; \ f -> f = identity
  7. two (succ one) ; \ f -> f . f = square
  8. three (succ two) ; \ f -> f . f . f = cube
  9. ; binary operations follow from succ:
  10. ((add g) f) ; the monoid on N
  11. ((f succ) g) ; \ g f x -> f x . g x = liftA2 (.)
  12. ((mul g) f) ; the monoid on End(N)
  13. ((f (add g)) zero) ; \ g f x -> f (g x) = (.)
  14. ; the rest are iterations of the "up arrow" map
  15. (((up op) g) f) ((f (op g)) one)
  16. pow (up mul) ; exponentiation ; \ f -> f = id = one
  17. tet (up pow) ; tetration, etc.
  18. (C n) (? n (succ (C (- n 1))) zero) ; fixnum -> N
  19. (N c) ((c (\ x (+ x 1))) 0)) ; N -> fixnum

fizzbuzz

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