LemonCake
A programming language that combines the speed of Ruby, with the flexibility of x86-64 Assembly, and the consistency of Lisp.
A programming language that combines the speed of Ruby, with the flexibility of x86-64 Assembly, and the consistency of Lisp.
Returns the smallest element.
Example:
> (min 5 8 3)
3
Returns the maximum element.
Example:
> (max 5 8 3)
8
The identity function. It returns what it receives.
Example:
> (identity 'something-here')
'something-here'
Creates a partial function.
Example:
> (= f (partial + 1 2))
> (f 4 1)
8
Which is the same as running:
> (+ 1 2 4 1)
8
Joins strings using a separator.
Example:
> (tie '_' :('a' 'b' 'c'))
'a_b_c'
Creates a list contaning `n` repetitions of a given value.
Example:
> (repeat 'a' 3)
('a' 'a' 'a')
Get the value from a list that's at zero-based index `i`.
Example:
> (at :(1 2 3) 2)
3(= at (~ (l i) (head ((apply comp (repeat tail i)) l))))
Generates a function that composes multiple functions that only accept one argument.
So given functions `f`, `g`, `h`, these two lines are equivalent:
(~ (x) (f (g (h x))))
(comp h g f)
Note that the functions are applied in the order in which they are given.
TODO Fix the order.
Example:
> (= plus1 (~ (x) (+ x 1)))
> (= double (~ (x) (list x x)))
> (= fn (comp plus1 double double))
> (fn 2)
((3 3) (3 3))
Pairs elements of lists together.
Example:
> (= names :('John' 'Bill' 'Alice'))
('John' 'Bill' 'Alice')
> (= ages :(31 21 27))
(31 21 27)
> (zip names ages)
(('John' 31) ('Bill' 21) ('Alice' 27))
Tests:
(zip :(1 2) :(a b))
((1 a) (2 b))
(zip :(1 2) :(a b) :(A B))
((1 a A) (2 b B))
(zip :(1 2 c) :(a b) :(A B))
((1 a A) (2 b B))
(zip :(1 2 c) :(a b c) :(A B))
((1 a A) (2 b B))
(zip :(1 2 c) :(a b c) :(A B c))
((1 a A) (2 b B) (c c c))
(+ 1 2)
3
(+ 8 4)
12
(+ 1 1)
(+ 2 3)
( + 44 11 ) #
2
5
55
()
(+ 1 2 3 4 5)
(+ 3 3 3)
15
9
(+ 2)
(+ 1 1 1 (+ 1 1))
2
5
(+ 1 -1)
0
(+ 100 -1000)
-900
:(0x00 0xc0)
:(0x00 0xc8)
:(0x00 0xd0)
:(0x00 0xd8)
:(0x00 0xe0)
:(0x00 0xe8)
:(0x00 0xf0)
:(0x00 0xf8)
:(0x00 0xc1)
:(0x00 0xc9)
:(0x00 0xd1)
:(0x00 0xd9)
:(0x00 0xe1)
:(0x00 0xe9)
:(0x00 0xf1)
:(0x00 0xf9)
:(0x00 0xc2)
:(0x00 0xca)
:(0x00 0xd2)
:(0x00 0xda)
:(0x00 0xe2)
:(0x00 0xea)
:(0x00 0xf2)
:(0x00 0xfa)
:(0x00 0xc3)
:(0x00 0xcb)
:(0x00 0xd3)
:(0x00 0xdb)
:(0x00 0xe3)
:(0x00 0xeb)
:(0x00 0xf3)
:(0x00 0xfb)
:(0x00 0xc4)
:(0x00 0xcc)
:(0x00 0xd4)
:(0x00 0xdc)
:(0x00 0xe4)
:(0x00 0xec)
:(0x00 0xf4)
:(0x00 0xfc)
:(0x00 0xc5)
:(0x00 0xcd)
:(0x00 0xd5)
:(0x00 0xdd)
:(0x00 0xe5)
:(0x00 0xed)
:(0x00 0xf5)
:(0x00 0xfd)
:(0x00 0xc6)
:(0x00 0xce)
:(0x00 0xd6)
:(0x00 0xde)
:(0x00 0xe6)
:(0x00 0xee)
:(0x00 0xf6)
:(0x00 0xfe)
:(0x00 0xc7)
:(0x00 0xcf)
:(0x00 0xd7)
:(0x00 0xdf)
:(0x00 0xe7)
:(0x00 0xef)
:(0x00 0xf7)
:(0x00 0xff)
(= endl (~ (ccall (dynsym 'libc.so' 'printf') '\n')))
(= a (~ (last
(repr (
apply (get asm-instr 'add') $args
))
(endl)
)))
(a 'al' 'al')
(a 'al' 'cl')
(a 'al' 'dl')
(a 'al' 'bl')
(a 'al' 'ah')
(a 'al' 'ch')
(a 'al' 'dh')
(a 'al' 'bh')
(a 'cl' 'al')
(a 'cl' 'cl')
(a 'cl' 'dl')
(a 'cl' 'bl')
(a 'cl' 'ah')
(a 'cl' 'ch')
(a 'cl' 'dh')
(a 'cl' 'bh')
(a 'dl' 'al')
(a 'dl' 'cl')
(a 'dl' 'dl')
(a 'dl' 'bl')
(a 'dl' 'ah')
(a 'dl' 'ch')
(a 'dl' 'dh')
(a 'dl' 'bh')
(a 'bl' 'al')
(a 'bl' 'cl')
(a 'bl' 'dl')
(a 'bl' 'bl')
(a 'bl' 'ah')
(a 'bl' 'ch')
(a 'bl' 'dh')
(a 'bl' 'bh')
(a 'ah' 'al')
(a 'ah' 'cl')
(a 'ah' 'dl')
(a 'ah' 'bl')
(a 'ah' 'ah')
(a 'ah' 'ch')
(a 'ah' 'dh')
(a 'ah' 'bh')
(a 'ch' 'al')
(a 'ch' 'cl')
(a 'ch' 'dl')
(a 'ch' 'bl')
(a 'ch' 'ah')
(a 'ch' 'ch')
(a 'ch' 'dh')
(a 'ch' 'bh')
(a 'dh' 'al')
(a 'dh' 'cl')
(a 'dh' 'dl')
(a 'dh' 'bl')
(a 'dh' 'ah')
(a 'dh' 'ch')
(a 'dh' 'dh')
(a 'dh' 'bh')
(a 'bh' 'al')
(a 'bh' 'cl')
(a 'bh' 'dl')
(a 'bh' 'bl')
(a 'bh' 'ah')
(a 'bh' 'ch')
(a 'bh' 'dh')
(a 'bh' 'bh')
(and 1)
1
(and 0 2)
0
(and 2 1)
1
(and 3 :(1) 'asdf' :ffff ())
()
(append (list) 1)
(1)
(append (list 3) 1)
(3 1)
(append (list 1 2) 3)
(1 2 3)
(append () ())
(())
(apply add :(1 5))
6
(apply (~ (a b) (add a b)) :(1 2))
3
(= putchar-ptr (dynsym 'libc.so' 'putchar'))
(= f (assemble (byte-explode
# mov rdi, 'A'
:(1 0xbf 0x41 0x00 0x00 0x00)
# mov rax, address_of_putchar
:(1 0x48 0xb8)
(list 8 putchar-ptr)
# call rax
:(1 0xff 0xd0)
# mov rdi, '\n'
:(1 0xbf 0x0a 0x00 0x00 0x00)
# mov rax, address_of_putchar
:(1 0x48 0xb8)
(list 8 putchar-ptr)
# call rax
:(1 0xff 0xd0)
# mov rdi, 'B'
:(1 0xbf 0x42 0x00 0x00 0x00)
# mov rax, address_of_putchar
:(1 0x48 0xb8)
(list 8 putchar-ptr)
# call rax
:(1 0xff 0xd0)
# ret
:(1 0xc3)
)))
(ccall f)
A
B
(= prog-bytes (byte-explode
# elf64_ehdr
:(1 0x7f 0x45 0x4c 0x46 2 1 1 0) # e_ident
:(8 0)
:(2 2) # e_type
:(2 0x3e) # e_machine
:(4 1) # e_version
:(8 0x4000b0) # e_entry
:(8 0x40) # e_phoff
:(8 0xe0) # e_shoff
:(4 0) # e_flags
:(2 0x40) # e_ehsize
:(2 0x38) # e_phentsize
:(2 2) # e_phnum
:(2 0x40) # e_shentsize
:(2 4) # e_shnum
:(2 3) # e_shstrndx
# elf64_phdr
:(4 1) # p_type
:(4 5) # p_flags
:(8 0) # p_offset
:(8 0x400000) # p_vaddr
:(8 0x400000) # p_paddr
:(8 0xbc) # p_filesz
:(8 0xbc) # p_memsz
:(8 0x200000) # p_align
:(4 1) # p_type
:(4 6) # p_flags
:(8 0xbc) # p_offset
:(8 0x6000bc) # p_vaddr
:(8 0x6000bc) # p_paddr
:(8 8) # p_filesz
:(8 8) # p_memsz
:(8 0x200000) # p_align
# .text
:(1 0xb8 0x3c 0x00 0x00 0x00) # mov rax 60
:(1 0xbf 0x2a 0x00 0x00 0x00) # mov rdi 42
:(1 0x0f 0x05) # syscall
# .data
:(8 0x0102030405060708)
# .shstrtab
:(1 0)
:(1 0x2e 0x73 0x68 0x73 0x74 0x72 0x74 0x61 0x62 0) # .shstrtab
:(1 0x2e 0x74 0x65 0x78 0x74 0) # .text
:(1 0x2e 0x64 0x61 0x74 0x61 0) # .data
:(1 0 0 0 0 0) # padding
# null section
:(4 0) # sh_name
:(4 0) # sh_type
:(8 0) # sh_flags
:(8 0) # sh_addr
:(8 0) # sh_offset
:(8 0) # sh_size
:(4 0) # sh_link
:(4 0) # sh_info
:(8 0) # sh_addralign
:(8 0) # sh_entsize
# .text section
:(4 0x0b) # sh_name
:(4 1) # sh_type
:(8 0x06) # sh_flags
:(8 0x4000b0) # sh_addr
:(8 0xb0) # sh_offset
:(8 0x0c) # sh_size
:(4 0) # sh_link
:(4 0) # sh_info
:(8 0x10) # sh_addralign
:(8 0) # sh_entsize
# .data section
:(4 0x11) # sh_name
:(4 1) # sh_type
:(8 0x03) # sh_flags
:(8 0x6000bc) # sh_addr
:(8 0xbc) # sh_offset
:(8 0x08) # sh_size
:(4 0) # sh_link
:(4 0) # sh_info
:(8 4) # sh_addralign
:(8 0) # sh_entsize
# .shstrtab section
:(4 0x01) # sh_name
:(4 3) # sh_type
:(8 0x00) # sh_flags
:(8 0) # sh_addr
:(8 0xc4) # sh_offset
:(8 0x17) # sh_size
:(4 0) # sh_link
:(4 0) # sh_info
:(8 1) # sh_addralign
:(8 0) # sh_entsize
))
(= prog (apply cat (map prog-bytes chr)))
(fs-write 'tmp_test_dir/prg' prog)
(ccall (dynsym 'libc.so' 'system') 'chmod +x tmp_test_dir/prg; ./tmp_test_dir/prg; echo $?')
42
(= a 1)
(repr a)
1
(= a 3)
(= foo-bar 5)
(repr (+ a foo-bar))
8
(= X 505 A 4040 aabbaa 110000)
(repr (+ aabbaa X A))
114545
(= a 2)
(= b (+ a 1))
(= c (+ b 100))
c
b
a
2
3
103
103
3
2
(= a 1)
a
(= a (+ 1 a))
a
(= a (+ a 1))
a
(= a 'asdf')
1
1
2
2
3
3
'asdf'
(at :(1 2 3 4) 0)
(at :(1 2 3 4) 1)
(at :(1 2 3 4) 2)
(at :(1 2 3 4) 3)
1
2
3
4
(& 12 6 13)
(& 0xff00000000000000 0x0f0000ff000000ff)
4
1080863910568919040
(| 1 2 4)
(| 0xff000000 0x0f0000ff)
(| 0xff00000000000000 0x0f0000ff000000ff)
7
4278190335
-72056498821267201
(byte-explode)
()
(byte-explode :(1 1))
(1)
(byte-explode :(1 8) :(1 9))
(8 9)
(byte-explode :(2 0x1122))
(34 17)
(byte-explode :(4 0x55443322) :(1 4))
(34 51 68 85 4)
(byte-explode :(8 0xffeeddccccddaaff) :(1 5) :(8 0xffeeddbbccddaaff))
(255 170 221 204 204 221 238 255 5 255 170 221 204 187 221 238 255)
(cat 'a' 'b')
'ab'
(cat 'aa' 'b')
'aab'
(cat '11' '2' '3333')
'1123333'
(ccall (dynsym 'libc.so' 'printf') 'asdf')
asdf
(ccall (dynsym 'libc.so' 'printf') 'asdf')
(ccall (dynsym 'libc.so' 'printf') 'another')
asdfanother
(= printf-func (dynsym 'libc.so' 'printf'))
(= printf (~ (a b) (ccall printf-func a b)))
(printf 'hello%lld' 3)
(printf 'hello%lld' 8)
(printf 'hello %s end' 'str')
hello3hello8hello str end
(ccall
(dynsym 'libc.so' 'printf')
'asdf %s %s %s %s %s'
'a' 'b' 'c' 'd' 'e'
)
asdf a b c d e
(= abs (~ (a) (ccall (dynsym 'libc.so' 'abs') a)))
(repr (abs 5))
(repr ' ')
(repr (abs -7))
(repr ' ')
(repr (abs -2147483647))
5' '7' '2147483647
# `$env` is the default variable representing the environment (a dict). Making
# this easier should be done in a macro.
(set $env (quote x) 4)
(repr x)
4
(set $env (quote x) 5)
(set $env (quote y) 4)
(set $env (quote z) (+ x y))
(repr z)
9
(chr 65)
'A'
(chr 39)
'\''
'b'#c
'b'
'bc' #d
'bc'
'bcd' #asdf
8
'bcd'
8
((comp (~ (a) (+ a 1)) (~ (a) (* a 3))) 2)
9
(dict)
(dict)
(dict (quote a) 1 (quote bb) 8 (quote ccc) 123)
(dict bb 8 ccc 123 a 1)
(/ 10 2)
5
(/ 10 3)
3
(- (dynsym 'libc.so' 'printf') (dynsym 'libc.so' 'printf'))
0
(= count 0)
(each
:(a b c)
(~ (= count (+ count 1)))
)
(repr count)
3
(= count 0)
(each
(range 10)
(~ (x) (if
(is x 5)
:$stop
(= count (+ count 1))
))
)
(repr count)
5
(repr 1)
# nothing
(repr 2) # something
(repr 44)
# end
1244
(len 'a\'b')
(len '\'b')
(len 'a\'')
(len '\'')
3
2
2
1
(len 'a\\b')
(len '\\b')
(len 'a\\')
(len '\\')
3
2
2
1
(len '\n')
(len 'a\n')
(len '\nb')
(len 'a\nb')
1
2
2
3
'a\'b'
'\'b'
'a\''
'\''
'a\nb'
'\nb'
'a\n'
'\n'
'a\\b'
'\\b'
'a\\'
'\\'
'a\'b'
'\'b'
'a\''
'\''
'a\nb'
'\nb'
'a\n'
'\n'
'a\\b'
'\\b'
'a\\'
'\\'
(eval 1)
(eval 'a')
(eval ())
(eval (dict 1 2))
(eval :(+ 1 2))
(eval (list :+ 1 3))
((eval :(~ (a b) (* a b))) 3 6)
(eval :(= a 3))
(eval :(- a 1))
1
'a'
()
(dict 1 2)
3
4
18
3
2
(fs-read 'tests/fs-read-001.in')
'(fs-read \'tests/fs-read-001.in\')\n'
(fs-write 'tmp_test_dir/wot' 'I am a file. What are you?')
(repr (fs-read 'tmp_test_dir/wot'))
pwd
cd ..
rm -fr tmp_test_dir
mkdir tmp_test_dir
cd tmp_test_dir
'I am a file. What are you?'
(= inc (~ (+ 1 (head $args))))
(repr (inc 2))
(repr (inc 5))
(repr (inc 22))
3623
# Test that you can override values outside of the function.
(= a 1)
(= increase-a (~ (= a (+ a 1))))
(repr a)
(increase-a)
(repr a)
(increase-a)
(repr a)
123
# Test that variables inside the function don't leak outside.
(= f (~ (= a 100)))
(repr a)
(f)
(repr a)
()()
# Test IIFE (immediately invoked function expression).
(repr (
(~ (+ 2 (head $args)))
2
))
4
# Function with named arguments.
(= sum (~ (a b) (+ a b)))
(repr (sum 1 4))
(repr (sum 1 2 3))
53
# Nested functions.
(= funcs ((~ (last
(= a 1)
(
dict
'inc-a' (~ (= a (+ a 1)))
'get-a' (~ a)
)
))))
# 'a' isn't available here.
(repr a)
# Get 1.
(repr ((get funcs 'get-a')))
# Increase.
((get funcs 'inc-a'))
# Get 2.
(repr ((get funcs 'get-a')))
()12
# Recursive function, yay!
(= fib (~ (n) (if
(is n 0) 0
(is n 1) 1
(+
(fib (- n 1))
(fib (- n 2))
)
)))
(repr (fib 2))
(repr (fib 3))
(repr (fib 4))
(repr (fib 5))
(repr (fib 6))
12358
(get (set (dict) 'name' 'John') 'name')
'John'
(get (set (set (dict) (quote a) 1) 'a' 2) 'a')
2
(hashcode 0)
0
(hashcode 1234)
1234
(hashcode 2395873184555)
2395873184555
(hashcode 'a')
177604
(hashcode 'base')
6382700272
(hashcode (quote base))
6382700272
(hashcode 'besa')
6382695920
(hashcode 'Paul Nechifor')
153306557046378463
(head (list 0 1 2))
0
(head (list 0 1 2))
0
(tail (list 0 1 2))
(1 2)
(head (tail (list 0 1 2)))
1
(tail (tail (list 0 1 2)))
(2)
(head (tail (tail (list 0 1 2))))
2
(tail (tail (tail (list 0 1 2))))
()
(identity 1234)
(identity :asdf)
(identity (~ (x) (+ 1 x)))
1234
asdf
(~ (x) (+ 1 x))
(if) # Expecting ().
()
(if 0)
0
(if 'a')
'a'
(if 1 'așa')
'așa'
(if 0 100)
()
(= a '')
(if a 'full' 'empty')
''
'empty'
(if 0 0 '' '' () () (dict) (dict) 'none-of-the-above')
'none-of-the-above'
((~ (a b) (+ a b)) 5 4)
9
(~ (n) (+ n n))
(= double-it (import './import-001-add.lcl'))
(repr (double-it 23))
46
(import './import-002-level2.lcl')
(~ (n) (+ n n))
(= double-it (import './import-002-level1.lcl'))
(repr (double-it 5))
10
(in 10 (dict 10 20))
1
(= d (dict 10 20 20 40 30 60))
(in 20 d)
(in 30 d)
(in 10 d)
(in 40 d)
(dict 10 20 20 40 30 60)
1
1
1
0
(is 4 4)
1
(is 4 3)
0
(is '4' 4)
0
(is 05 00005)
1
(is 'asdf' 'asdf')
1
(is 'asde' 'asdf')
0
(is 'asdf' 'asdfe')
0
(join :(1 2) :(3 4))
(1 2 3 4)
(join :('_' 'a') :('_' 'b') :('_' 'c'))
('_' 'a' '_' 'b' '_' 'c')
(last)
()
(last 1)
1
(last 'a' 'b' 'c')
'c'
(last (+ 1 2))
3
(last (+ 100 1 10) (+ 400 20 5))
425
(len 'a')
1
(len '1234')
4
(len '')
0
(len ())
0
(len (list 1))
1
(len (list 1 2))
2
(len (list 1 2 3))
3
(len (dict))
0
(len (dict))
(len (dict 1 11))
(len (dict 1 11 4 44))
0
1
2
()
()
() # asdf
()
(list )
()
(list 1)
(1)
(list 1 )
(1)
( list 22 )
(22)
( list 22 )
(22)
(list 1 2 3)
(1 2 3)
(list 1 'asdf' 3)
(1 'asdf' 3)
(list 1 (list 22 33) 3)
(1 (22 33) 3)
(list (list 1 'df' (list 'asf') () (list 'bb' ) ) 123)
((1 'df' ('asf') () ('bb')) 123)
(list 1 2 (quote aaa))
(1 2 aaa)
(list 1 (+ 1 2 3) 'asdf')
(1 6 'asdf')
(set $env :two (macro :(+ 1 1)))
(repr (two))
2
(set $env :x 20)
(set $env :y 300)
(set $env :foo (macro :(+ x 1 y)))
(repr (foo))
321
(=
=~
(macro
(name args function)
(list
:=
name
(list
:~
args
function
)
)
)
)
(=~ sum (a b) (+ a b))
(repr (sum 1 2))
3
(= add-with (macro (base) (list
:~
:(n)
(list :+ :n base)
)))
(= adder-5 (add-with 5))
(repr (adder-5 10))
(repr (adder-5 100))
(= adder-123 (add-with 123))
(repr (adder-123 1000))
(repr (adder-123 1))
151051123124
(map :(1 2 3) (~ (a) (+ a 1)))
(2 3 4)
(map :(5 6 7 8) (~ (n i) (+ n i)))
(5 7 9 11)
(- 1 1)
(- 100 10)
(- 5000 -6000)
(- -5000 6000)
(- -10000 -20020)
(- 123 99999)
0
90
11000
-11000
10020
-99876
321
'str'
123
321
'str'
123
'asdf'
43215
'asdf'
43215
(* 4 3)
12
(* 2 2 4 100)
1600
(repr 1)
(repr 2)
12
1
(repr 123)
123
(repr 'asdf')
(repr 1)
(repr (+ 1 2 3))
'asdf'16
()
1234
(repr 1)
()
(repr '
')
8
(repr 8888)
1'\n'8888
(+ 1 2 (+ 3))
6
(+ 1 2 (+ 3 4))
10
(+ 1 1 (+ 1 (+ 1 (+ 1 1) 1 (+ 1 1))))
9
()
# Just a comment.
()
# Indented comment.
()
4
4
1234
5
1234
5
-123
44
-124
-1
-111111111111111111
1234789012347890
-123
44
-124
-1
-111111111111111111
1234789012347890
(< 1 2)
(< 1 -1)
(< 1 2 0)
(< 1 2 9)
(<= 1 2)
(<= 1 1)
(<= 1 1 0)
(> 2 1)
(> -1 1)
(> 2 1 3)
(> 2 1 -4)
(>= 2 1)
(>= 5 5)
(>= 1 2)
1
0
0
1
1
1
0
1
0
0
1
1
1
0
(or 1)
1
(or 0)
0
(or :())
()
(or 0 1)
1
(or 1 0)
1
(or 0 :() 0 0 :())
()
(pair 1 :(2 3))
(pair 1 :())
(pair :(1) :(1))
(1 2 3)
(1)
((1) 1)
(= inc (partial add 1))
(repr (inc 1))
(repr (inc 6))
27
(quote x)
x
(quote (a b))
(a b)
(range 5)
(0 1 2 3 4)
(range 10 15)
(10 11 12 13 14)
(range 10 5 -1)
(10 9 8 7 6)
(map (range 5) (~ (a) (* a a)))
(0 1 4 9 16)
(reduce add :(1 2))
3
(reduce add :(1 2 3))
6
(reduce add :(6) 500)
506
(reduce add :(1 2 1 2 1 2 1 2) 10000)
10012
(repeat 9 0)
(repeat 1 1)
(repeat 1 2)
(repeat 'a' 3)
()
(1)
(1 1)
('a' 'a' 'a')
(replace 'aaxa' 'a' '-')
'--x-'
(replace 'aaXaaXaaa' 'aa' '[]')
'[]X[]X[]a'
(replace 'dog eat dog here' 'dog' 'kitty')
'kitty eat kitty here'
(repr 'one')
'one'()
(repr 'str1')
'str1'
'str1'
(set (dict) 'name' 'John')
(dict 'name' 'John')
(set (set (dict) 'name' 'John') 1 2)
(dict 1 2 'name' 'John')
(= l :(1 2 3))
(set-head l 5)
l
(set-head (tail l) 6)
l
(1 2 3)
5
(5 2 3)
6
(5 6 3)
(= l :(1 2 3))
(set-tail l ())
l
(set-tail l :(7))
l
(set-tail (tail l) :(8))
l
(1 2 3)
()
(1)
(7)
(1 7)
(8)
(1 7 8)
(<< 1 1)
(<< 1 2)
(<< 1 3)
(<< 0xf000000000000000 1)
(<< 1 63)
2
4
8
-2305843009213693952
-9223372036854775808
1
2
16
1
(>> 2 1)
(>> 16 2)
(>> 0xf000000000000000 60)
(>> 0x8000000000000000 63)
(split ' ' 'a b c')
('a' 'b' 'c')
(split 'aa' 'aaJJJaaaMMMMM')
('' 'JJJ' 'aMMMMM')
(split 'aa' 'aaJJJaaaMMMMMaa')
('' 'JJJ' 'aMMMMM' '')
(split '' 'abcdef')
('a' 'b' 'c' 'd' 'e' 'f')
(stitch)
()
(stitch ())
()
(stitch () () ())
()
(stitch :(1 2))
(1 2)
(stitch :(5 2) :(88 123))
(5 2 88 123)
(stitch :(1 2 3) :(5 55 555) :(-1 -2 -3))
(1 2 3 5 55 555 -1 -2 -3)
'asdf'
'asdf'
'aa bb '
'aa bb '
(repr '
a
ccc
b
')
'\n a\n ccc\n b\n'
(switch 1 1 :one)
one
(switch 2 1 :one)
()
(switch 2 1 :one :other)
other
(switch 2 1 :one 2 :two)
two
(quote asdf)
asdf
(quote <=>)
<=>
(list (quote asdf))
(asdf)
(list (quote asdf) 1 (quote ab))
(asdf 1 ab)
(list (quote a) (quote s) (quote d) (quote f) 'x' (list 1 (quote ab)))
(a s d f 'x' (1 ab))
(list (quote xx) 'yy')
(xx 'yy')
(list (quote a) (quote b))
(list (quote a) (quote b))
(list (quote a) (quote b))
(a b)
(a b)
(a b)
(list (quote aa) (quote bb) (quote cc))
(list (quote a) (quote c))
( list (quote a) (quote b) (quote c) ) # Nothing here
(list (quote cc) (quote dd))
(aa bb cc)
(a c)
(a b c)
(cc dd)
(ccall (dynsym 'libc.so' 'system') 'echo hello world')
hello world
($trap 4)
($trap (+ 1 2))
($trap ($entrap 5))
($trap (+ 1 2 ($entrap 'a')))
($trap (if 1 ($entrap 'b')))
($trap (if 0 ($entrap 'b') (+ 4 4)))
($trap (+ 1 2 ($entrap (+ 8 8))))
4
3
5
'a'
'b'
8
16
(= f (~ (a b) ($trap (last
(= ret 0)
(map (range a b) (~ (a) (if (- a 10)
(= ret (+ ret a))
($entrap (list 'will not go above 10' ret a))
)))
ret
))))
(repr (f 2 20))
(repr (f 2 5))
('will not go above 10' 44 10)9
(= ă 'litera ă mică')
ă
'litera ă mică'
'litera ă mică'
1234
1234
'a'
'a'
12
12345
55
12
12345
55
(zip :(1 2) :(a b))
(zip :(1 2) :(a b) :(A B))
(zip :(1 2 c) :(a b) :(A B))
(zip :(1 2 c) :(a b c) :(A B))
(zip :(1 2 c) :(a b c) :(A B c))
((1 a) (2 b))
((1 a A) (2 b B))
((1 a A) (2 b B))
((1 a A) (2 b B))
((1 a A) (2 b B) (c c c))