Lisp dialect written in Python
sudo pip3 install liscript
lirepl # open liscript repl
lirun <filename> # run liscript code
;; Atoms
x ; will return the value of variable `x'
;; Getters & properties
(:x obj) ; will return property `x' of object (or dictionary) `obj'
obj:x ; the same as above
;; Numbers
1
1.5
-1
;; Strings
"Hello, world!"
;; Expressions (lists)
(+ 1 2) ; apply function `+' to 1 and 2; will return 3
;; Quoted lists
'(1 (+ 1 1) (+ 1 1 1)) ; elements are evaluated when the list is initialized; will return '(1 2 3)
;; Lazy lists
[1 (+ 1 1) (+ 1 1 1)] ; elements are evaluated manually; will return [1 (+ 1 1) (+ 1 1 1)]
;; Dictionaries
{:x 1
:y 2
:z 3}
> (let [x d] 0 {:a 1 :b 2})
> (let [d:c] 3)
> x
-> 0
> d:c
-> 3
> (modify [x] [+ 1]) ; same as `(let [x] (+ 1 x))'
> x
-> 1
> (def [sqr x] [* x x]) ; same as `(let [sqr] (fn [x] [* x x]))'
> (sqr 9)
-> 81
> (class [Point] {:constructor (fn [self x y] [let [self:x] x] [let [self:y] y])})
> (let [p] (new Point 3 5))
> p:x
-> 3
> p:y
-> 5
> (+ 1 2)
-> 3
> (- 5 1)
-> 4
> (* 2 3)
-> 6
> (/ 5 2)
-> 2.5
> (> 1 2)
-> #f
> (< 5 1)
-> #f
> (= 2 2)
-> #t
> (!= 5 2)
-> #t
> (if #t [say "true"] [say "false"])
true
> (unless #t [say "true"] [say "false"])
false
> (case [= 1 0] [say "1 = 0"] [> 1 0] [say "1 > 0"] otherwise [say "1 < 0"])
1 > 0
> (list 1 2 3)
-> '(1 2 3)
> (cons 1 '(2 3))
-> '(1 2 3)
> (head '(1 2 3))
-> 1
> (tail '(1 2 3))
-> '(2 3)
> (push 3 '(1 2))
-> '(1 2 3)
> (!! '(1 2 3) 1)
-> 2
> (slice '(1 2 3 4 5 6 7 8 9 10) 5)
-> '(6 7 8 9 10)
> (slice '(1 2 3 4 5 6 7 8 9 10) 1 5)
-> '(2 3 4 5)
> (eval-list '(+ 1 2))
-> 3
> (eval-list [* 2 2])
-> 4
> (read)
user input
-> "user input"
> (say "hello, world")
hello, world
> (exit) ; exit with code 0