My parents are in town, and my dad makes me laugh, makes me think, makes me crazy, and always, always makes me cry. And thinks it's funny. Stupid bully. Sorry to interrupt the celebrations here, but please, I need a hug.
Posts: 26077 | Registered: Mar 2000
| IP: Logged |
I understand completely. I love my father, and pretty much came to terms with him several years back... but I still want to strangle him on at least a semi-annual basis. Have strength for the rest of the visit.
Posts: 7954 | Registered: Mar 2004
| IP: Logged |
posted
tch, tch, Hobbes, using a method like GiveHobbesHug. How about GiveHugFrom(Hobbes) (with Hobbes created as a person -- Person Hobbes = new Person("Hobbes");
Posts: 15770 | Registered: Dec 2001
| IP: Logged |
(oh, and to save my sanity I'm going to assume those variables are all nicely encased in a block of some kind, Leto, and are thus not contaminating the global namespace -- I'm already traumatized by writing php code because of all sorts of awful practices it makes necessary).
Posts: 15770 | Registered: Dec 2001
| IP: Logged |
posted
Uh, Leto, my program was in Haskell. Namespaces don't work the same way (in fact, the language as a whole doesn't work the same was as most any language you've used, I think). And Hobbes's was preventing contamination (effectively) by using objects.
What I wrote was a complete program, btw
and many more ((((((((kat)))))))) hugs.
Posts: 15770 | Registered: Dec 2001
| IP: Logged |
posted
I still say you should make the argument of giveHug a Person argument. That would open up a lot of possibilities for extension -- for isntance, you could increment in the function the number of hugs that person had given out, or maybe have an associative array as a member with keys being the names (or better, some form of unique identifier autogenerated through a Person metaclass) of people Hugs are given to so you knew who had been hugged.
posted
(btw, Hobbes, you better hope that function actually does inline . And I wouldn't count on it, unless you're really turning up the optimization flags. However, I definitely support writing it that way, because the number of hugs needed might change with time (which would of course be accomodated by changing the gethugsneeded method to calculate the ones currently needed at any given time).
Though in that case it would probably be better to move all hug counting logic into the Person class, and use a while loop. Actually, that would be good even now. So whenever a hug was given you internally tally up another hug, and make the loop something like this (also including my shtick about the argument of giveHug: Person Hobbes = new Person("Hobbes"); while(Kat.needsHugs()){ Kat.giveHug(Hobbes); }
posted
I'm sorry the benefits of having your family around come with so much baggage, Katie You certainly deserve better, as demonstrated by your putting up with them so long (and let me tell you, that's far better than I would do)
Hope it's over quick, and that it goes with minimum jerkiness by your old man. Drop me an email if you'd like an ear to lease (Low, low rates!)
Posts: 17164 | Registered: Jun 2001
| IP: Logged |
posted
considering you just wrote a semantically 'while' construct with a for loop, you shouldn't be talkin' on loops, Leto .
Also, while his code is more complicated, it is also significantly more reusable, and could be incorporated, with relatively minor changes, into a number of systems. If you just want a once off solution, fine, but its often better to take a little time in the beginning and write something semantically rich, reusable, and extensible. If you tried to write a major program in the style you're writing in, it would be a very hairy undertaking. Hobbes's code would fit in just fine. (Note, this is not intended as a criticism, or even really a response to your previous comment, just an observation of the differences, as I observe the difference with mine below).
Mine was just for the sheer pleasure of mapping a print function onto an infinite list (I love lazy evaluation) .
posted
I went to a lot fo steps to do it for two reasons, one is, as Fugu mentions, reuseability. I don't reuse code all that much, but I've gotten in the habit of writting code that at least can be. I feel like it's a good habit.
Second, is that I feel that this implementation is relfective of the physcial meaning. Two people, I started off sending the function in the for loop a Person class that had been constructed with "Hobbes" because that would be even more explict representation, however I realizied that would cause file problems so I left it at sending a charecter array (though you'll notice class Person is capable of excepting a Person class when giving a hug).
Also, as a programmer, the infinite loop, while cute, struck me as overkill, and probably would kill Kat from over-hugging.
And I ran in circles, but I ran in circles intentionally .
In fact, your for loop is the one that would run forever, you put the conditional in the wrong place. That first bit only evaluates once, and it doesn't do anything at all (its supposed to hold initialization procedures, and by its nature requires side effects for anything to happen. Your operation has no side effects). You have no conditional, and no iteration step.
So all that would happen is your for loop would call hug(Kat) forever (I'm assuming Kat is assigned a value somewhere).
Posts: 15770 | Registered: Dec 2001
| IP: Logged |
Just to comment some more on Haskell, and break down what my program did:
code:
kathugs = "(((kat)))" : kathugs
main = map putStrLn kathugs
The first line assigns kathugs (not really a variable in the sense of a C program) a list which consists of the value "(((kat)))" followed by . . . . itself. This constructs an infinite list. In a non-lazy language, this would be a problem, because in the attempt to evaluate itself the structure would keep cycling forever. However, in a lazy language this is not problem -- I could then say something like takeFirst kathugs and it would return the first element of kathugs -- "(((kat)))", despite that there were infinitely more elements there it wouldn't bother Haskell one bit, because it ignored them, not needing them to find the first element.
The second line assigns to the variable main. Main is a special value for Haskell compilers -- its the entry point of the program, like the function main in c. The value of main must always be a function (of type IO) that takes no arguments. However, Haskell has a really, really good type inference system, so in most programs you never need to write out a type signature.
the value of main is map putStrLn kathugs. This just maps the function putStrLn (which outputs a string with a newline) to the list kathugs. Since Haskell is lazy, it does it to one element after the other, not caring what all the elements afterwards are until it gets to them. As such it keeps going forever down the infinite list.
Its worth pointing out that while my program used recursion, it did not use any loops.
Posts: 15770 | Registered: Dec 2001
| IP: Logged |
Heya Katie! Sorry thats happening to you, and sorry theres not much I can do about it, otherwise I would. Also, sorry that I have no advice, or silly little code to put here. But hey, you're totally awesome and cool!
posted
{{{{Kat}}}} <-- Those were freely given. No cashing of any sympathy thread a year card here.
I know it can be a difficult thing when family can make you feel horrible. It seems to go against all logic. People who are family -- blood -- should know how not to hurt you, but more often than not the opposite is true. Just remember that family is a not only a word defined by genetics but by the spirit, and you definitely have some family here.
posted
I only laughed when I saw Pop's code. I can actually understand that code!!!
Anyhow, I'm sorry kat. (hugs kat) My dad sometimes comes close to that... he usually steps back before I get REALLY upset.
Posts: 4816 | Registered: Apr 2003
| IP: Logged |
If I were there, I'd hide out in the bathroom with you. Or we could sneak out the back door and grouch about life together. *smile
Just remember, it will be over eventually. It may be awful meanwhile, but it will be over, and you will have your own space to yourself. I'd suggest some milk & cookies and a LM Bujold book myself, but you can figure out what's best for you.
I'm sorry you have to go through with this. Don't worry, you get all the sympathy cards you want.
Posts: 14017 | Registered: May 2000
| IP: Logged |
posted
(((((kat))))) I'm sorry the much-anticipated visit is causing you pain. Family is complicated!!! Good luck, sweetie -- and hugs whenever you need 'em!