Advertisement
alestane

Sequence iterator

Feb 12th, 2013
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.31 KB | None | 0 0
  1. local function split(test, f, s, v)
  2.     local bridge = v
  3.     local function filter(...)
  4.         bridge = ...
  5.         if test(...) then
  6.             return nil
  7.         else
  8.             return ...
  9.         end
  10.     end
  11.  
  12.     local function head(s, v)
  13.         return filter(f(s, v))
  14.     end
  15.     return function() return head, s, v end, function() return f, s, bridge end
  16. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement