diff options
| author | unwox <me@unwox.com> | 2024-09-26 17:46:38 +0600 |
|---|---|---|
| committer | unwox <me@unwox.com> | 2024-09-26 17:46:38 +0600 |
| commit | 9b82db238f9e2e02a76f95c793f8d6ef2387ecfd (patch) | |
| tree | cdb2a16d01f09553b560ab1034d53392d07bae42 /lib/macro.fnl | |
init
Diffstat (limited to 'lib/macro.fnl')
| -rw-r--r-- | lib/macro.fnl | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/macro.fnl b/lib/macro.fnl new file mode 100644 index 0000000..f23b1fb --- /dev/null +++ b/lib/macro.fnl @@ -0,0 +1,18 @@ +(fn map [f l] + `(icollect [i# v# (ipairs ,l)] + (,f i# v#))) + +(fn filter [f l] + `(icollect [i# v# (ipairs ,l)] + (if (,f i# v#) + v# + nil))) + +(fn reduce [f l s] + `(accumulate [r# ,s + i# v# (ipairs ,l)] + (,f i# v# r#))) + +{: map + : filter + : reduce} |
