HN user

YogSothoth

34 karma
Posts0
Comments15
View on HN
No posts found.

I'm with you alex, I tend to only use classes when I've got to maintain state, I just use a function otherwise. Here's how I'd likely code this ...

  #include <iostream>
  #include <string>
  #include <cmath>
  
  using std::string;
  using std::cout;
  using std::endl;
  
  static bool findRoots(
     double a,
     double b,
     double c,
     double &rootOne,
     double &rootTwo,
     string &errMsg
  )
  {
     if(a == 0.0)
     {
        errMsg = "Parameter 'a' cannot be zero";
        return(false);
     }
  
     double discriminant = b * b - 4 * a * c;
  
     if(discriminant < 0.0)
     {
        errMsg = "Discriminant cannot be less than zero";
        return(false);
     }
  
     double dSqrt = sqrt(discriminant);
     double twoA  = 2 * a;
  
     rootOne = (-b + dSqrt) / twoA;
     rootTwo = (-b - dSqrt) / twoA;
  
     return(true);
  }
  
  int main()
  {
     double a[] = { 0.0, 2.0, 2.0 };
     double b[] = { 1.0, 3.0, 1.0 };
     double c[] = { 2.0, 2.0, 0.0 };
  
     double rootOne;
     double rootTwo;
     string errMsg;
  
     for(int n = sizeof(a) / sizeof(a[0]), i = 0; i < n; i ++)
     {
        cout << "a: " << a[i] << ", b: " << b[i] << ", c: " << c[i] << endl;
  
        if(findRoots(a[i], b[i], c[i], rootOne, rootTwo, errMsg))
        {
           cout << rootOne << " " << rootTwo << endl;
        }
        else
        {
           cout << errMsg << endl;
        }
  
        cout << endl;
     }
  
     return(0);
  }

A buddy of mine showed me a cool trick to avoid this type of problem. What you do is first use SELECT to see the records in question:

   SELECT * from some_table where idx >= 5
Then, once you are staring at the records that came back (and are sure they are the ones you want to delete), change SELECT * to DELETE (and change nothing else) and rerun.
   DELETE from some_table where idx >= 5
Pretty hard to get it wrong with this approach ;-)

Definitely second the recommendation of Lilith's Brood, I also found it very moving. I bought it based upon the strength of her (much) earlier short story Bloodchild which I found myself thinking about for weeks after I'd read it.

Suppose you were a news outlet and suppose you were trying to maximize your company's profitability.

Clearly,when folks change the channel away from your program, your profitability goes down. So, you might do a bit of research to find out what tends to make folks change or not change the channel.

Your research could indicate that strong negative emotions, such as anger, sadness or fear tend to make the viewer fixate and not change the channel.

Finally, you might ask yourself, how should the news be presented so as to maximize profits?

In many cases, a news outlet's profitability is directly related to the amount of emotional distress it can generate in its viewers. Sure isn't something I want to support when looked at that way.

Yep, when I ride my bike in the early morning, I purposefully do not wear light-colored or reflective clothing. I don't want to ever believe for a nanosecond that my safety is anyone's job but mine so I prefer to view the cars as actively trying to hit me and work to make it impossible for them to do so. The relationship (cars and bikes) is fundamentally adversarial in nature, best to act like it.

I cannot think of any exercise that's more likely to build up one's self control over time than meditation. The ability to keep one's attention squarely on the meditation object (typically the breath) for as long as one wishes improves self control and focus immensely over time.

If you've never experienced it, the feeling of having zero thoughts in your head for an extended period of time is just absolutely stunning/amazing/whatever - worth experiencing like you wouldn't believe.

I'm thinking this might be more like head shops. They sell water pipes that are surely used almost exclusively for illegal activities but can be used for non-illegal activities (i.e. smoking tobacco). I don't recall the head shops being asked to produce an actual example of a person smoking tobacco through one of their water pipes, how does this differ exactly?

I immediately close any site that does this - don't care what they are offering/selling - if they behave this way, I guarantee their wares aren't worth bothering with.

It's almost like looking at code, I generally only have to look at the formatting. You don't see a lot of lame code that's impeccably formatted (nor a lot of useful websites that do that in-your-face type of advertising).

I don't doubt the CRA is part of it, but I think the fed lowering and lowering and lowering the prime rate after 9/11 in order the stimulate the economy figured prominently as well.

With interest rates low, banks have to be more aggressive in pursuing borrowers to maintain their same level of profitability (i.e. they'll start considering loaning to folks they'd normally not loan to). Also, with interest rates low, there was a housing market boom which convinced a lot of people they could make money buying houses on credit and flipping them.

It makes you wonder if we'd have been better off if we'd have just let the economy recover on its own after 9/11. The fed lowering the prime rate did hasten the onset of economic recovery 7 years ago, but look where we are now.

Three prisoners were sitting in a U.S. jail, found guilty of "economic crimes" and were also comparing stories. The first one said, "I charged higher prices than my competitors, and I was found guilty of profiteering, monopolizing and exploiting consumers." The second one said, "I charged lower prices than my competitors, and I was found guilty of predatory pricing, cutthroat competing and under-charging." The third prisoner said, "I charged the same prices as my competitors, and I was found guilty of collusion, price leadership and cartelization."