Skip to content

eczn/se

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lisp dialect: se

SE

the implementation of se inspired from Scheme

Usage

$ 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>

Example

here: example

Syntax

define

(define var
    (+ 1 1))

(define (add x y)
    (+ x y))

lambda

(define (double x)
    (+ x x))

(define double-2
    (lambda (x) (+ x x)))

recurse

(define (sum n)
    (if (> n 0)
        (+ n (sum (- n 1)))
        0))

;; 5 + 4 + 3 + 2 + 1 + 0 = 15
(log (sum 5))

point args & apply args

(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

cons

(load "lib/main.se")

(define pair
    (cons 1 2))

(log (car pair))
(log (cdr pair))

list

(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))

Checklist

  1. parse s-expression
  2. define & lexical scope
  3. lambda & closure invoke
  4. recursive invoke
  5. if statement control stream
  6. variable length parameter
  7. cons & list

License

MIT

About

🔣 lisp dialect in ts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published