https://github.com/zac-garby/zzzz
A lazy Lisp.
https://github.com/zac-garby/zzzz
hacktoberfest lazy-evaluation lisp
Last synced: 11 days ago
JSON representation
A lazy Lisp.
- Host: GitHub
- URL: https://github.com/zac-garby/zzzz
- Owner: zac-garby
- License: mit
- Created: 2019-04-05T16:28:33.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-26T17:51:33.000Z (about 6 years ago)
- Last Synced: 2025-04-04T15:52:59.212Z (3 months ago)
- Topics: hacktoberfest, lazy-evaluation, lisp
- Language: Haskell
- Homepage: https://zac-garby.github.io/zzzz/
- Size: 557 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
zzzz
A non-strict, dynamically typed lisp, which compiles to lambda calculus.
![]()
## Examples
```
zzzz> (defun foldr (f i xs)
zzzz| (if (eq xs [])
zzzz| i
zzzz| (f (head xs) (foldr f i (tail xs)))))
λf.λi.λxs.(((if ((eq xs) [])) i) ((f (head xs)) (((foldr f) i) (tail xs))))zzzz> (foldr + 0 [1 2 3])
6
```
> Higher-order functions and currying (of the `+` function).```
zzzz> (defun repeat (x)
zzzz| (cons x (repeat x)))
λx.((cons x) (repeat x))zzzz> (defun take (n xs)
zzzz| (if (eq n 0)
zzzz| []
zzzz| (cons (head xs) (take (- n 1) (tail xs)))))
λn.λxs.(((if ((eq n) 0)) []) ((cons (head xs)) ((take ((- n) 1)) (tail xs))))zzzz> (take 10 (repeat 0))
[0 0 0 0 0 0 0 0 0 0]
```> Lazy data structures. In this case, taking the first 10 elements of an infinite list of zeros.