[erlang-questions] How to return all records in dets

Loïc Hoguin essen@REDACTED
Sun Jun 1 16:04:46 CEST 2014


I'm all for comments, but I don't see how it would be at all usable 
using disqus. Take this page for example: 
http://www.erlang.org/doc/man/erlang.html

Where do you put the comments? They're going to be unnoticed, and 
they're going to cover a wealth of different topics so much that they'll 
become entirely useless.

Make one comment zone per function? Disqus is already painfully slow to 
load when there's one, so imagine 50 or 100.

Joe's solution is nice and tidy on the other hand. But there's one 
problem though, who's going to moderate?

There's no real quick way to that kind of stuff. At least not with this 
amount of content.

On 06/01/2014 11:38 AM, Mark Nijhof wrote:
> Just a thought on commenting, but adding a disqus comment section to
> each page might be a real quick way to enable that. Just add it to the
> templates you use for generating the html. Later it should also be
> rather easy to migrate them somewhere else if needed.
>
> -Mark
>
> On Jun 1, 2014 11:09 AM, "Joe Armstrong" <erlang@REDACTED
> <mailto:erlang@REDACTED>> wrote:
>
>
>
>
>     On Sat, May 31, 2014 at 8:44 PM, <lloyd@REDACTED
>     <mailto:lloyd@REDACTED>> wrote:
>
>         Hi Joe,
>
>         I've resorted to approach 0 many times and much appreciate the
>         generous help I've received from the community. Indeed, response
>         from the author of my Erlang bible is particularly awesome. I
>         hope one day to be competent enough to play it forward.
>
>         I also spend a great deal of time in the Erlang man pages.
>         Problem is that I'm one of those soft-headed liberal arts types.
>         So, I often find the man pages near incomprehensible (and not
>         only Erlang). Yes, I perhaps should have taken more math classes
>         to grasp the elegant concision. But my mind doesn't seem to be
>         wired that way.
>
>         I can't tell you how many times I've looked at the foldl/n docs
>         and tried to understand what the hell is going on. I get the
>         general drift, but can't bring it down to useful code. There's
>         just too much inside-baseball.
>
>         As a self-taught-from-books-and-web Erlang aspirant, I find
>         concrete examples and well-written tutorials most helpful. This
>         gives me leverage to apply your approach 3. In general, the
>         concepts of Erlang are simple enough once I grasp them. In fact,
>         I marvel at the pragmatic elegance. Your books provide
>         particularly lucid explications. But the man pages? My how I
>         wish I had the time and chops to write a parallel set for noobies.
>
>         Indeed, would it be helpful if I walked through and commented on
>         the man doc items that give me headaches?
>
>
>     Absolutely - There is a problem here - which I think should be
>     addressed as soon as
>     possible - "It is not easy to common and ask question about man pages" -
>     I'd really like to see commenting in the style of the real world
>     Haskell book.
>
>     If you're interested take a look at
>     http://book.realworldhaskell.org/read/types-and-functions.html - in
>     particular look at how comments are added to the text.
>
>     The erlang man pages are generated from XML so a commenting system
>     should be
>     easy to make.
>
>     I'd like to see questions about the man pages discussed "inside the
>     man pages"
>     if you see what I mean - not "outside the man pages" (ie here)
>     ...
>
>     Folds are very common there are the "iterators with an accumulator"
>
>     In an imperative language you might say
>          state = state0
>          for(i in x){
>              state = update(state, f(i))
>          }
>
>     In erlang this is a fold
>
>          fold(F, State0, X)
>
>     F is a function of I and State which returns a new state, and I iterates
>     over the values in X
>
>     so
>
>         fold(fun(I, S) -> I + S end, 0, L)
>
>     is the same as
>
>          S = 0;
>          for(I in L){
>             S = S + I
>         }
>
>     This is a very common programming pattern
>
>     Cheers
>
>     /Joe
>
>
>
>         Many thanks again for your kind help,
>
>         Lloyd
>
>         -----Original Message-----
>         From: "Joe Armstrong" <erlang@REDACTED <mailto:erlang@REDACTED>>
>         Sent: Saturday, May 31, 2014 1:53pm
>         To: "Lloyd Prentice" <lloyd@REDACTED
>         <mailto:lloyd@REDACTED>>
>         Cc: "Erlang-Questions Questions" <erlang-questions@REDACTED
>         <mailto:erlang-questions@REDACTED>>
>         Subject: Re: [erlang-questions] How to return all records in dets
>
>         The thing to Google for is "dets man erlang" - which should get
>         you the man
>         page
>         (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
>         might mean
>         "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
>         operation that
>         traverses all objects in the collection)
>
>         To print all records
>
>            dets:traverse(Name, fun(X) ->
>                                     io:format("~p~n",[X]),
>                                     continue
>                                end)
>
>         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
>         incomprehensible
>              4) search Google/stackoverflow
>
>         Cheers
>
>         /Joe
>
>
>
>         On Fri, May 30, 2014 at 9:56 PM, <lloyd@REDACTED
>         <mailto:lloyd@REDACTED>> wrote:
>
>          > Hello,
>          >
>          > 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,
>          >
>          > LRP
>          >
>          >
>          >
>          > _______________________________________________
>          > erlang-questions mailing list
>          > erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
>          > http://erlang.org/mailman/listinfo/erlang-questions
>          >
>
>
>
>
>     _______________________________________________
>     erlang-questions mailing list
>     erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
>     http://erlang.org/mailman/listinfo/erlang-questions
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>

-- 
Loïc Hoguin
http://ninenines.eu



More information about the erlang-questions mailing list