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

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 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.

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