From 464255a53558e9b2466b76e37432cafe8e7894c6 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Wed, 4 Jun 2025 15:34:37 +0100 Subject: add pairs_except --- pairs_except.lua | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 pairs_except.lua diff --git a/pairs_except.lua b/pairs_except.lua new file mode 100644 index 0000000..1f808ec --- /dev/null +++ b/pairs_except.lua @@ -0,0 +1,8 @@ +-- pairs_except(t, k) is the same as pairs(t), but with t[k] skipped +return function(t,exception) + if exception == nil then return pairs(t) end + local function next_except(t,k) + local k2,v2 = next(t,k) + if k2 == exception then k2,v2 = next(t,k2) end + return k2,v2 end + return next_except, t, nil end -- cgit v1.2.3