Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

scheme iteration

Name: Anonymous 2008-12-12 5:13

hi guys. i have just been learning scheme and i was wondering how im meant to do iteration. i cant figure out how to do a while loop can anyone help me? does it use a different word or something?

Name: Anonymous 2008-12-12 5:17

Have you read SICP?

Name: Anonymous 2008-12-12 5:37

fact n = foldl1 (*) [1..n]

Name: Anonymous 2008-12-12 5:42

>>3
It takes my machine five seconds to calculate fact 30000. Is this okay?

Name: Anonymous 2008-12-12 6:19

>>2
The correct phrase is "Have you read your SICP today?"

Name: Anonymous 2008-12-12 6:39

>>4
Check your prompt. Does it happen to say something like ``irb(main):059:0>''?

Name: Anonymous 2008-12-12 7:52

so none of you know how to do a while loop in scheme>

Name: Anonymous 2008-12-12 8:01

Of course we know, we've already read our SICP. Our philosophy is to "teach a man to fish rather than giving him the fish". Read SICP and you shall be enlightened.

Name: Anonymous 2008-12-12 8:16

so scheme doesnt even havea while loop?

Name: Anonymous 2008-12-12 8:40

How much plainer can we get? Read SICP to get the answer.

Name: Anonymous 2008-12-12 8:49

fuck this. what a shit language

Name: Anonymous 2008-12-12 9:38

>>6
No. What's that?

Name: Anonymous 2008-12-12 9:41

>>1
0/10

Name: Anonymous 2008-12-12 10:35

>>9
Scheme doesn't have have a while loop, because it uses recursion instead of iteration. You can use iteration in Scheme, but it's pretty complicated because you have to emulate the iteration using recursion. You can do this using the Y combinator like so:
((lambda (x) (display "lol dongs") (x x)) (lambda (x) (display "lol dongs") (x x)))

As you can see it requires a lot of code to do a simple iteration in Scheme, so if you want to use iteration it's better to use an iterative language such as C++ or Python.

Name: Anonymous 2008-12-12 10:38

Name: Anonymous 2008-12-12 12:16

>>14
You mean if you want iteration it's better to use Common Lisp, which provides more and better loops than Sepples or FIOC.

Name: Anonymous 2008-12-12 13:07

Name: Anonymous 2009-03-06 6:06


iteration does seem to   be listing those.

Don't change these.
Name: Email:
Entire Thread Thread List