Hacker News new | ask | show | jobs
by boxfire 2125 days ago
I think this was posted purely for the limerick quality.
3 comments

  There was a young coder whose hacks
  His manager often claimed lacked
  The requisite clarity
  For to clamp vars would he:
  Math.min(Math.max(number, min), max);

    @jaffathecake had a problem of truncation
    and posted to Twitter his calculation.
    The gist of his attack
    was min( max( num, min ), max)
    yet refused to add any annotation.
In a file of utility hacks

near get(), post(), and ajax()

// we alias at import

// to keep all the code short

min(max(number, min), max)

Haiku is nice, too:

    Cryptic sorcerer!
    "Math.min(Math.max(v, min), max);"
    his incantation.