From 8fdf428ca9c668f7a186721d39e9ba857bec77e6 Mon Sep 17 00:00:00 2001 From: Andrey Orst Date: Tue, 16 Feb 2021 03:25:22 +0300 Subject: fix: update seq-fn semantics --- macros.fnl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/macros.fnl b/macros.fnl index 81845fe..ccb6855 100644 --- a/macros.fnl +++ b/macros.fnl @@ -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)))) -- cgit v1.2.3