lisp dialect: se
the implementation of se inspired from Scheme
$ git clone https://github.com/eczn/se.git
$ cd se
$ npm i
$ tsc
# cli tool
$ npm link
$ se ./example/play.se
cli usage:
$ se <file>
here: example
(define var
(+ 1 1))
(define (add x y)
(+ x y))
(define (double x)
(+ x x))
(define double-2
(lambda (x) (+ x x)))
(define (sum n)
(if (> n 0)
(+ n (sum (- n 1)))
0))
;; 5 + 4 + 3 + 2 + 1 + 0 = 15
(log (sum 5))
(load "lib/main.se")
(define (add-all a . b)
(if (null? a)
0
(+ a (apply add-all b))))
(log
(add-all 1 2 3 4 5))
;; 15
(load "lib/main.se")
(define pair
(cons 1 2))
(log (car pair))
(log (cdr pair))
(load "lib/main.se")
(define (double x)
(+ x x))
(define my-lst
(list 1 2 3 4))
(log "for-each")
(for-each log my-lst)
(log "map")
(for-each log
(map double my-lst))
- parse s-expression
- define & lexical scope
- lambda & closure invoke
- recursive invoke
- if statement control stream
- variable length parameter
- cons & list
MIT