[erlang-questions] How to return all records in dets
Sat May 31 19:53:35 CEST 2014
The thing to Google for is "dets man erlang" - which should get you the man
(even better is to store the man pages locally and do "erl -man dets")
You want to "list" all records (I'm not sure what list means here - it
"print" or "make a list of").
To make a list of all records you could say:
dets:foldl(fun(X, L) -> [X|L] end, , Name)
(Most collections - ie dets, ets, dict, etc. offer some kind of fold
traverses all objects in the collection)
To print all records
dets:traverse(Name, fun(X) ->
No need to worry about match specifications.
The best place to start is usually by reading the man pages.
Now that Erlang is is becoming popular you'll find a lot of incorrect
solutions to problems posted on stackoverlow.
Best approach is
0) ask an expert
1) read the man pages for the module, in question
2) experiment with the functions in the man pages in the shell
3) ask/tell this list if the manual pages are ambiguous or
4) search Google/stackoverflow
On Fri, May 30, 2014 at 9:56 PM, <lloyd@REDACTED> wrote:
> I'm cross-eyed from looking at match specifications. All I want to do is
> list all records in my small dets table. I once ran across a very neat
> query to accomplish that, but for the life can't Google it up.
> Can some kind soul give me a query that works?
> Many thanks,
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions