in reply to Daniel Barlow

@dan "I haven't found a nice way to iterate through an array and return the first element that matches a predicate (as far as I can tell, an early return from an each is not possible) but I'm sure there must be one" i've never heard of fennel until now (it looks pretty neat), the docs recommend installing lume or luafun for map, reduce, and filter

self reply

@dan looking at those, lume has match:
lume.match({1, 5, 8, 7}, function(x) return x % 2 == 0 end) -- Returns 8, 3
luafun doesn't seem to have a direct way of doing it, but it has lazy iterators/lists, so you can do (untested):
head(map(function(x) return x % 2 == 0 end, {1, 5, 8, 7})) -- Returns 8

self reply
self reply