Skip to content

Instantly share code, notes, and snippets.

@kyokpae
Created March 26, 2012 16:17
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 kyokpae/2206274 to your computer and use it in GitHub Desktop.
Save kyokpae/2206274 to your computer and use it in GitHub Desktop.
dets bag example
#!/usr/bin/env escript
main(_) ->
dets:open_file(store, [{type, bag}, {file, 'store'}]),
dets:insert(store, {a, a}),
dets:insert(store, {a, b}),
dets:insert(store, {a, c}),
dets:insert(store, {b, b}),
dets:insert(store, {c, a}),
dets:insert(store, {c, b}),
lists:foreach(fun(Query) ->
io:format("query is: '~p'. result is: ~p~n", [Query, dets:match(store, {'$1', Query})])
end, [a, b, c]),
dets:close(store).
@kyokpae
Copy link
Author

kyokpae commented Mar 26, 2012

output:

query is: 'a'. result is: [[a],[c]]
query is: 'b'. result is: [[a],[b],[c]]
query is: 'c'. result is: [[a]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment