From d9a08de4d8cb47a30026c20cddb48cea04e099d4 Mon Sep 17 00:00:00 2001 From: elioat Date: Fri, 28 Oct 2022 21:10:57 -0400 Subject: * --- chibi/print.scm | 2 +- lil/play.lil | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 lil/play.lil diff --git a/chibi/print.scm b/chibi/print.scm index 376cdf4..5f58a23 100644 --- a/chibi/print.scm +++ b/chibi/print.scm @@ -13,4 +13,4 @@ (prints "kiwi" "banana" "pineapple") -(print "hi") \ No newline at end of file +(print "hi") diff --git a/lil/play.lil b/lil/play.lil new file mode 100644 index 0000000..8f83664 --- /dev/null +++ b/lil/play.lil @@ -0,0 +1,56 @@ +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 do (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 =) -- cgit 1.4.1-2-gfad0