[HELP] Single questions & Help Thread [n00b] (66)

1 Name: chester copperpot : 2008-04-30 00:02 ID:Heaven

Why do we need a method to determine if a stack is empty?

2 Name: #!/usr/bin/anonymous : 2008-04-30 01:51 ID:pPcLAyBH

>>1
Context, numb-nuts? Comprende? Now give me 20 push-ups and a reworded question.

3 Name: #!/usr/bin/anonymous : 2008-04-30 02:12 ID:Heaven

>>2
context: stack implementation

4 Name: #!/usr/bin/anonymous : 2008-05-01 07:55 ID:nEXP+bJr

why not? makes things clearer.

5 Name: #!/usr/bin/anonymous : 2008-05-03 13:51 ID:V7mp15x0

Can anyone explain to me what side-effects are?
I read about them in wikipedia, but I'm still kinda confused.
Are they bad, good, why do we care about them? A nice little practical example would be much appreciated.

6 Name: #!/usr/bin/anonymous : 2008-05-03 14:36 ID:PGHeLRr1

>>5
side effects are things like changing the state of some variable in a program and IO. Without side effects, the order in which you execute two expressions, s1 and s2, makes no difference. They aren't good or bad per se. Purely functional languages don't have side effects.

This: http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-19.html#%_chap_3 is a good read too.

7 Name: #!/usr/bin/anonymous : 2008-05-03 15:46 ID:mxqboWJt

>>6

They must have some side effects or they would never interact with the anything outside of themselves. You just side IO was a side effect.

8 Name: #!/usr/bin/anonymous : 2008-05-03 22:12 ID:PGHeLRr1

>>7

Well... you don't really need a print statement, the result of whatever function you evaluate in the repl will just be returned to the interpreter and printed. But yeah, for a practical language, you need IO.

9 Name: #!/usr/bin/anonymous : 2008-05-03 23:50 ID:Heaven

>>8
For a practical language, you need a lot more than just IO.
You need a system that allows side effects (look at monads in haskell)
Also, C doesn't have actual IO. It's all file streams writing/reading.
You can make all read calls to return EOF, and all write calls to return success without doing anything.
Replace fopen() calls with NULL macros, etc etc, and your implementation would still be valid. Not practical, but C allows it.

10 Name: CSS Question : 2008-05-04 18:46 ID:V7mp15x0

How do I define a CSS rule for an HTML element with just an id and not a class?

11 Name: #!/usr/bin/anonymous : 2008-05-04 23:06 ID:5o1YB8rR

>Why do we need a method to determine if a stack is empty?

Otherwise the program might allow the user to try to take another element out, which might make the program end up in weird memory locations that it shouldn't be.

12 Name: #!/usr/bin/anonymous : 2008-05-04 23:06 ID:5o1YB8rR

>Why do we need a method to determine if a stack is empty?

Otherwise the program might allow the user to try to take another element out, which might make the program end up in weird memory locations that it shouldn't be.

13 Name: #!/usr/bin/anonymous : 2008-05-04 23:49 ID:Heaven

>>12
well, that was easy.

14 Name: #!/usr/bin/anonymous : 2008-05-05 00:19 ID:Heaven

>>10

#id { text-decoration: blink; }

15 Name: #!/usr/bin/anonymous : 2008-05-18 02:42 ID:R8Zq53Q9

Run in the Python interpreter:

>>> 2 / (2.0+3)

0.40000000000000002

How did the .00000000000000002 get into that float?

This thread has been closed. You cannot post in this thread any longer.