Go Down

Topic: WAY OFF TOPIC, but I would like some help getting my head around this. (Read 3053 times) previous topic - next topic

lost_and_confused

Ok, this is more to do with PROGRAMMING, but here is a good place to ask, becaues it is to do with "definitions" - I think.

Ok:

How far can a dog run into a forest?

Read more: http://wiki.answers.com/Q/How_far_can_a_dog_run_into_a_forest#ixzz27j2hkI7J


Now I don't know of the exact subtle differences between:

How far into a forest can a dog run?

But...

The answer is "half way" because then he is running OUT of the forest.

Now I sort of understand that, but my question is:
If the dog is running "into" the forest, he doesn't know when he is halfway there, so continues to run anyway.

Now, it is said that after "halfway" he is running out, so the answer is "half way".  But wouldn't it be "all the way" because as soon as he starts to run "out of the forest" - when he gets halfway there, he is no longer runnning INTO the forest anyway?




You guys being knowledgeable programmers may be able to explain this to me in a way I can understand and help me clear up the confusion with the definitions.

johnwasser

The answer is relative to your frame of reference.

Relative to the dog, the dog has run "all the way" into the forrest when the tip of the dog's tail crosses the forrest boundary.

Relative to the forrest, the dog runs into the forrest "half way".  After passing the middle point on the path from forrest boundary to forest boundary the dog is no longer running "in to" but "out of" the forrest.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

lost_and_confused

John,

If I wasn't a bloke as well, I'd give you a big hug for helping me understand that.

It has been haunting me for a long time and I haven't really got a good answer until now.

Thanks much.

lost_and_confused


The answer is relative to your frame of reference.

Relative to the forrest, the dog runs into the forrest "half way".  After passing the middle point on the path from forrest boundary to forest boundary the dog is no longer running "in to" but "out of" the forrest.


Ok, just one more question though on that last bit.

So the question asks:
How far can a dog run into a forest?

So it is specified INTO.

So although looking at it from the forest's point of view, the dog would still run "all the way" INTO the forest then start to run "all the way" OUT OF it.

So wouldn't the answer still be "all the way"?   (With the question worded like that)
Just asking.

Graynomad

Rob Gray aka the GRAYnomad www.robgray.com

lost_and_confused

Yeah, but as people here (I hope) have a better understanding of programming and what is defined and what isn't, they may be able to help me with all the terms, declorations and what not.


Graynomad

I have a pretty good understanding of programming but I don't really see a programming question here, like I said it seems more like a Zen-style definition of the word "into". These ambiguities do bite you in the arse in a specification and that's when you have to nail down what the customer means by "into".

And then there's the definition of a dog? Is it the head, nose, tail?

But after that has been properly defined the programming should be the (often simple) implementation of an algorithm.

What if the forest is not circular and the dog changes direction? In an instant it has moved from 50% through to 90% through. Did it travel faster than light or even instantly?

Much as these musings are interesting I cannot yet see a concrete question about "programming and what is defined and what isn't" and "the terms, declarations and what not".

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

lost_and_confused

Yeah, granted Rob.

But as a "noob" I don't know the lingo.

I am saying "declarations" "definitions" etc..... because they are the words I feel best fit my problem.

So excuse me if I am not using the right words and their definitions, only because I don't know better.

So if you don't mind, teach me the meanings of these words as well so I can be smarter - though I won't promise it will work.

GoForSmoke

One question is about how far the dog runs.

The other question amounts to how far is it to the middle of the forest.

I see where this applies to approach to code, like where you want the code to get versus what the code must do to get there. When time/money is involved, replace code with development and just listen to what people who (think they) know the ends but nothing about the means. It gets real relevant then!

Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts


jraskell

As Graynomad mentioned, this is the biggest hurdle in converting requirements into code.  Requirements can be of varying levels of ambiguity.  There is zero ambiguity in code.

In this case, the phrase 'into the forest' needs to be more specifically defined.  Without that definition,  any answer is just an interpretation that may or may not be correct.  It could be half way, it could be all the way.  It could be something else entirely if 'into the forest' has some non-intuitive meaning.  For example, it could just as easily mean a single step if 'into the forest' is simply a binary state.

Graynomad

#11
Sep 28, 2012, 04:41 pm Last Edit: Sep 28, 2012, 04:44 pm by Graynomad Reason: 1
Re declaration and definition, I think you'll have to hit the books but I found this on the web.

Quote
In The Definition of a variable space is reserved and some initial value is given to it, whereas a declaration only identifies the type of the variable for the function. Thus definition is the place where the variable is created or assigned storage whereas declaration refers to places where the nature of the variable is stated but no storage is allocated.


I admit I get them confused as well but the following is right I think

Code: [Select]
void myFunc(void);    // declaration of myFunc() so the compiler knows what to expect if the function is referenced before it is defined
//
// lots of other code
//
void myFunc(void) {   // definition if myFunc, this is the bit that actually has the code
   // some code
}


You need the declaration if you have a forward reference to a function for example

Code: [Select]
loop () {
   myFunc();
}

void myFunc(void) {   
   // some code
}


Will cause an error because the compiler sees the reference to myFunc() before it knows what the heck it is. One way to fix this is to declare the function first.

Code: [Select]
void myFunc(void);   // this is also called a "prototype"

loop () {
   myFunc();
}

void myFunc(void) {   
   // some code
}


The declaration (AKA prototype) tells the compiler what myFunc() is so when it sees the reference in the loop() function it's happy in the knowledge that myFunc() exists, the call is correct WRT parameters and return type, and that at some point myFunc() will be defined.

You can also fix this by simply placing myFunc() before any code that references it but often this is not practical.

The Arduino IDE pulls a trick to help beginners with this. It scans the program for forward references and (I think) inserts declarations for you.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

AWOL

And if a tree falls and there's only the dog in there, does it make a sound?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

lost_and_confused

Ah, the fun of programming.

Ok, again and more off topic, here is an e-mail which I just received which is sort of quaint and long these lines:



There was a bit of confusion at the Sporting goods store this morning. When I was ready to pay for my purchases of gun powder and bullets the cashier said, "Strip down, facing me."
Making a mental note to complain to Harper about the gun registry people running amok, I did just as she had instructed.
When the hysterical shrieking and alarms finally subsided, I found out that she was referring to my credit card.
I have been asked to shop elsewhere in the future.
They need to make their instructions to us seniors a little clearer!


Ya gotta laugh.

Coz if you didn't you would cry.

Graynomad

Probably most of English comedy is based on assumptions and ambiguities. As a programmer I tend to take what someone says literally, as a normal person I usually interpret but I have a habit of doing literally what my missus says just for fun.

For example she may hand me some rubbish and say "Take this out to the bin and throw it out". 3 minutes later I return with the rubbish having thrown the bin out.

She laughs and laughs...sometimes.

______
Rob

Rob Gray aka the GRAYnomad www.robgray.com

Go Up