Skip to content

Instantly share code, notes, and snippets.

@maximvl
Created November 1, 2013 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maximvl/7263882 to your computer and use it in GitHub Desktop.
Save maximvl/7263882 to your computer and use it in GitHub Desktop.
ets:select(Tab, [{{'$1', '_', '_', '_'},[],['$1']}], 10).
{[{1383242643,746081},
{1383293043,948240},
{1383292743,966571},
{1383287643,925604},
{1383261243,820525},
{1383260043,828302},
{1383243543,748386},
{1383240243,743004},
{1383234543,716093},
{1383229443,690387}],
F = fun(X, N, F) -> case N of 0 -> []; N1 -> E = ets:next(Tab, X), [E|F(E,N-1,F)] end end.
#Fun<erl_eval.18.80484245>
(receiver@127.0.0.1)41> F(ets:first(Tab), 10, F).
[{1383234543,716093},
{1383240243,743004},
{1383243543,748386},
{1383260043,828302},
{1383261243,820525},
{1383287643,925604},
{1383292743,966571},
{1383293043,948240},
{1383242643,746081},
{1383276543,880893}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment