Okay, so I'm writing some shit in DrScheme (http://www.plt-scheme.org/, basically it's a derivative of LISP) and I'm trying to figure out how the fuck I should go about implementing iteration. I wrote some quite decent code using for loops to avoid the complicated recursion hell that LISP tends to subject you to but now that I go to run it, it keeps throwing up this error:
reference to undefined identifier: for
Basically, wtf is this shit? PLT Scheme guide section 11 is pretty clear that things like
(for ([i '(1 2 3)])
(display i))
are perfectly valid scheme. Am I missing something painfully obvious, or is something really fucked up going on?
Yes, I know you can recite /prog/ memes. Can you give useful answers instead?
Oh, and to illustrate why I'm finding this so frustrating, that code which I posted, which the manual says works? Yeah, well if you copy and paste it into the scheme terminal then it still tells you for is an undefined identifier. I feel like there must be an import I'm missing or something, but I can't see anything in the manual page about requiring an import. And actually the idea of having to import a module in order to implement recursion just seems fucking ridiculous.
So yeah, anyone familiar with Scheme or LISP want to help? I don't want to have to write the (for (ident list) (procedure)) function by hand...
It's funny, because, here, reading SICP, is not just a meme, but a valid advice. I'm serious, OP, read SICP, chapters 4 and 5.
Name:
Anonymous2009-03-29 7:54
We tell people to read SICP because it contains the fucking answers. If everybody read SICP, /prog/ would be much quieter because everybody would already know the answers to their stupid questions.
Name:
Anonymous2009-03-29 7:55
SICP - The New Bible.
Name:
Anonymous2009-03-29 7:59
We tell people to read Bible because it contains the fucking answers. If everybody read Bible, /prog/ would be much quieter because everybody would already know the answers to their stupid questions.
Name:
Anonymous2009-03-29 8:03
Speaking of memes, hax my anux *grabs dick*.
Name:
Anonymous2009-03-29 8:05
>>4
To the best of my knowledge, scheme doesn't have a for loop. Usually, you implement iteration through recursion. If you had read even a small amount of the wizard book you would know that.
I think however you're looking for for-each i.e.
(for-each display (list 1 2 3))
Name:
Anonymous2009-03-29 8:05
SICP is good and all, but this really strikes me as a situation where either the compiler is not working or I need an import that isn't clearly specified in the manual. And since I have four assignments two tests and a group presentation this week, I really don't have time to read through SICP again for an answer that I doubt is even in there.
I'm mainly asking because I want to know if there is something completely outside of simple programming that is causing the failure like "scheme version 4.14 has a broken implementation of iteration" or some shit like that. I'm pretty certain my for loops are well designed, and I know for sure that the for loops I'm copying straight from the manual into the terminal are well designed but in both cases it's telling me that a simple library call is an undefined identifier.
Name:
Anonymous2009-03-29 8:06
Bible is good and all, but this really strikes me as a situation where either the compiler is not working or I need an import that isn't clearly specified in the manual. And since I have four assignments two tests and a group presentation this week, I really don't have time to read through Bible again for an answer that I doubt is even in there.
Thanks for being helpful. And yeah, I know that usually you implement iteration through recursion in scheme, I just got lazy because of time pressures and recursion having a tendency to do my head in if I spend too long working with it. About half my code is properly done with recursion, but after spending all day coding this shit I kinda got fed up with the headaches.