From 30991649f817d1653752b93519133a4cff1279e8 Mon Sep 17 00:00:00 2001 From: rxi Date: Fri, 4 Apr 2014 18:08:39 +0100 Subject: [PATCH] Added lume.match() --- lume.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lume.lua b/lume.lua index 5b79d55..a0b75fc 100644 --- a/lume.lua +++ b/lume.lua @@ -201,6 +201,14 @@ function lume.find(t, value) end +function lume.match(t, fn) + for k, v in pairs(t) do + if fn(v) then return v, k end + end + return nil +end + + function lume.slice(t, i, j) i = i and absindex(#t, i) or 1 j = j and absindex(#t, j) or #t