about summary refs log tree commit diff stats
path: root/html/playground/counter.html
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2024-12-22 11:10:47 -0500
committerelioat <elioat@tilde.institute>2024-12-22 11:10:47 -0500
commit204328ef0d73fd0fed75737b780023d8f07fd488 (patch)
tree2f60968811032dfa4b2e78d58f5a685410309361 /html/playground/counter.html
parent97f98d4f223147ade7f0351ded18136d56c967cb (diff)
downloadtour-204328ef0d73fd0fed75737b780023d8f07fd488.tar.gz
*
Diffstat (limited to 'html/playground/counter.html')
0 files changed, 0 insertions, 0 deletions
bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
(local lume (require :lume))

(local kv {:abc 123 :def 456 :xyz 789})
(local seq [123 456 789])

(fn even? [x] (= (% x 2) 0))

;; map a function over a table. note that the table is the first arg.
(lume.map seq (fn [x] (* 3 x))) ; -> [369 1368 2367]

;; keep or drop elements from a table based on a predicate function.
(lume.filter seq even?) ; -> [456]
(lume.reject seq even?) ; -> [123 789]

;; the classic reduce, aka foldl; run a function over everything in
;; the table with an accumulator value.
(lume.reduce seq (fn [acc x] (+ acc x))) ; -> 1368

;; return a new table with all the keys and values from any number of tables.
;; right-most arguments take precedence.
(lume.merge seq kv {:abc 963})
;; -> { :abc 963 :def 456 :xyz 789 1 123 2 456 3 789 }

;; unlike most of the other functions here, the extend function
;; modifies its first argument rather than returning a fresh table:
(local newtable {:qrs 147 :tuv 258})
(lume.extend newtable {:jkl 999})
newtable ; -> { :jkl 999 :qrs 147 :tuv 258 }

;; return all the keys in a table:
(lume.keys kv) ; -> ["xyz" "def" "abc"]

;; return the key under which a given value is first found in a table:
(lume.find seq 456) ; -> 2
(lume.find kv 789) ; "xyz"

;; similar to find, except use a predicate function instead of a value.
;; returns both the value matched and its index:
(lume.match seq even?) ; -> 456 2

;; select a subset of keys from a table:
(lume.pick kv :abc :xyz) ; -> { :abc 123 :xyz 789 }

;; finally we have a handful of miscellaneous non-table-related functions.

;; oddly Lua does not ship with a string splitting function; use this instead:
(lume.split "diode,capacitor,switch" ",") ; -> ["diode" "capacitor" "switch"]

;; generate a QUID and return a string representation:
(lume.uuid) ; -> "d6cce35c-487a-458f-aab2-9032c2621f38"