diff options
| author | Andrey Orst <andreyorst@gmail.com> | 2021-02-16 03:25:22 +0300 |
|---|---|---|
| committer | Andrey Orst <andreyorst@gmail.com> | 2021-02-16 03:25:22 +0300 |
| commit | 8fdf428ca9c668f7a186721d39e9ba857bec77e6 (patch) | |
| tree | b83d0af3498c1bf77b1ed3b2f658e556dfffa268 | |
| parent | dd97368330bb772c481bdf8e7ca8b110d5a16bbb (diff) | |
fix: update seq-fn semantics
| -rw-r--r-- | macros.fnl | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -108,7 +108,14 @@ (let [assoc-res# (setmetatable {} {:cljlib/type :seq})] (each [k# v# (pairs col#)] (if (and (not assoc?#) - (not (= (type k#) :number))) + (if (= (type col#) :table) + (let [m# (or (getmetatable col#) {}) + t# (. m# :cljlib/type)] + (if t# + (= t# :table) + (let [(k# _#) ((or m#.cljlib/next next) col#)] + (and (not= k# nil) + (not= k# 1))))))) (set assoc?# true)) (insert# res# v#) (insert# assoc-res# [k# v#])) @@ -131,10 +138,10 @@ `(fn [tbl#] (let [t# (type tbl#)] (if (= t# :table) - (let [meta# (getmetatable tbl#) - table-type# (and meta# (. meta# :cljlib/type))] + (let [meta# (or (getmetatable tbl#) {}) + table-type# (. meta# :cljlib/type)] (if table-type# table-type# - (let [(k# _#) (next tbl#)] + (let [(k# _#) ((or meta#.cljlib/next next) tbl#)] (if (and (= (type k#) :number) (= k# 1)) :seq (= k# nil) :empty :table)))) |