maps are everything. an experiment in language construction with an inicidental lisp syntax.
we use lisp syntax, kind of. definitions use def
. maps use curly braces.
commas and colons are whitespace. calling maps is indexing into them.
functions are infinite maps, i.e. maps that do not precompute. they take inputs and produce output. hence, their syntax looks like this:
{(input args) -> (output expression)}
because i am lazy, lisp is easy to parse, and syntax doesn’t matter. i mean, did you look at the error messages?
the fun is in the definitions.
true
is the map with one entry. false
is the empty map. anything else is
not a boolean (but you can make it one by using (neg (empty? <map>))
).
numerical values are maps with n
entries. any map can be an integer. there is
a reader expression for array syntax using brackets; it just generates the
indices. there are reader literals, but since the only way to generate a key is
to generate a recursively different map, any number over 5 is gnarly, and over
25 it becomes borderline unusable. fun.
maps with integral keys can be used like arrays.
or: is this your card?
conditionals are maps from true
and false
to other values. we can thus
define the function
(def if
{(cond a b) -> (({true a false b} cond))}) ; branches are nullary infinite maps
multi-branch conditionals work the same way, but there is no function for them.
loops happen when we iterate over maps. you have foldr
, map
, and filter
at your disposal.
(def print-all-keys {(m) -> (map {(k v) -> (prn k)} m)})
if you have pure bounded functions, why not express them as maps instead? computation is an illusion of numbers in time anyway.
it is maptional programming, naturally.
yes, you should.
mae is not currently being developed, but, if you want to show your love, be kind to someone else.