about summary refs log tree commit diff stats
path: root/lil/play.lil
blob: 70ed9e3102c5e878c5a8c860615274336bbcec8c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# all lifted from <https://beyondloom.com/decker/lil.html>

on mode a do
	r:()
	each x in a
		r[x]:1+r[x]
	end
	extract first key orderby value desc from r
end

m:mode[1,2,2,3,4,2,1]

print[m]

show[
	-(100,200)+(10,-20)/(3,3)
]

show[
	each x in 2 cross 3 (27,19)+x end
]

people.name:"Alice","Sam","Thomas","Sara","Walter"
people.age:25,28,40,34,43
people.job:"Developer","Sales","Developer","Developer","Accounting"
people:table people

t:select from people

show[t]

s:select where ("S%m" parse name) from people

show[s]

d:select where ("Developer" = job) from people

show[d]

a:select name where ("Alice" = name) from people

show[a]


needle:   "apple"
haystack: ("frog","apple","chicken","toadstool","apple","rice","fish")

c:0 each x in haystack if x~needle c:c+1 end end c     # imperative
show[c]

g:0 each x in haystack g:g+x~needle end g              # imperative, without a conditional
show[g]

show[extract count value where value=needle from haystack]   # query

show[count needle take haystack]                             # functional (filter)

show[sum needle=haystack]                                    # vector-oriented (spread-conforming =)