• Kleyguerth (github)

    function matchFrist(frist, comments) { comments.forEach(c => if (c === first) updateFrist(frist)) }

  • RLB (unregistered)

    Frist branch, all the way to the bottom!

  • Amazing (unregistered)

    First: Nice test for the JavaScript stack handling and size. But does the earch even stop after the ONE note passed as param was found and updated?

  • (nodebb)


  • dpm (unregistered)

    Either I'm slow this morning or some parents were being incremented multiple times.

  • 14 (unregistered)

    In other words, it’s the sort of thing you really don't want to exist.


  • Mr Bits (unregistered)

    The original author of that code is likely the kind of person who walks around searching in vain for his coffee mug, all the while holding it in his hand.

  • tbo (unregistered) in reply to Kleyguerth

    When is this website going to just ban all the "frist" comments. It was stupid on slashdot 20 years ago, and it's stupid now.

  • Little Bobby Tables (unregistered) in reply to tbo

    When everybody in the world has lost their sense of humour and become like you.

  • annanonymous coward (unregistered) in reply to Little Bobby Tables

    when the no fun zone is so bad the person with the old xkcd reference name is the voice of reason and levity

  • (nodebb) in reply to tbo

    If it were just "FRIST!" we did unofficially ban it because it got old, and unoriginal. Please note the comments now incorporate something from the article in every Frist comment. So please take your lack of humor someplace else, this site has been far from serious for years, a quick trip through the forums should tell you that.

  • (nodebb)

    As as the fristers never ever ever have a negative comment on what they think is stupidity by either the article's subject or author, I say go ahead and be stupid.

    Addendum 2018-12-18 12:00: "As long as"

  • Guest (unregistered)

    You mean replace all with updateParentCounters(widget, folder);

  • Kleyguerth (github) in reply to tbo

    Ever since I started reading this site (years ago) "Frist" comments were clearly parodying people who rush for "Frist!", but incorporating stuff from the article. There isn't even a rush for it, I took my time reading the article, noticed there was no comments and decided to keep on with the tradition, I took my time to think of something, reread the article, but I'm just not that funny, so I just did a parody of the code but using an imaginary comment list instead of a tree.

    This is a fun site, to make fun of bad code and authors of bad code, if you want serious stuff go find a serious forum or read the news.

    I'd agree with you if it was a simple "FRIST11!1" comment, but there is more to it than that.

  • DrPepper (unregistered)

    This is a perfect example of how easy it is to get into trouble when you use recursion. So, just stop and think for a minute: what am I actually trying to do? Or if you can't do that, well, you're in the wrong profession then.

  • Sole Purpose of Visit (unregistered) in reply to DrPepper

    Actually it's a rubbish example of how "easy" it is to get into trouble when you use recursion. Vice versa, it would be a rubbish example of how "easy" it is to get into trouble when you use iteration or loops.

    In terms of a Turing machine, there's no difference between the two approaches. One maps on to the other. Watch out for stack overflow, which is the only real problem existing in one form but not in the other ... but this particular post does not involve stack overflow. For those using recursion -- Map-Reduce, Kids!

    It is a good example of how to fail dismally at (a) understanding the problem (b) examining the tools to solve that problem and (c) breathing through your mouth, however.

  • staticsan (unregistered)

    This shows the real problem with deploying clever, elegant and efficient code and structure - there's always a dev who can add a method to make it dumb, clumsy and inefficient.

  • Doug (unregistered) in reply to Kleyguerth

    Kleyguerth: my favorite part is that you've failed to misspell "first" in one spot, so the code will not do what the reader expects...

  • RLB (unregistered) in reply to Kleyguerth

    So did I, but apparently you pressed Submit between me fetching the empty page and pressing Submit myself... you dastardly frist-stealer, you!

  • jay (unregistered)

    From the Devil's DP Dictionary:

    recursion (n): See "recursion"

  • jay (unregistered)

    Years ago I heard a comedy routine that made fun of some silly things people say all the time. One that the comic made fun of was, "When I find it, it will be in the last place I look!" Well, duh, he said, why would you keep looking for it after you found it?

    Yet I've seen many programs that search a data structure that do not exit when they find the thing they're looking for, but keep looking for it.

  • (nodebb)

    Sounds like a common problem for languages with this kind of typing. Something like C# or even (gasp!) VB would give a better chance of noticing widget is already a tree node.

  • Anon (unregistered)

    That's not equivalent! The original code returns root.items (assuming root.items.items doesn't exist), while the new code doesn't return anything.

Leave a comment on “Trim the Tree”

Log In or post as a guest

Replying to comment #:

« Return to Article