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

Pages: 1-

Iteration in DrScheme

Name: Anonymous 2009-03-29 7:19

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?

Name: Anonymous 2009-03-29 7:31

>>1
Read SICP.

Name: Anonymous 2009-03-29 7:44

Scheme, now you have 2 problems.

Name: Anonymous 2009-03-29 7:47

>>2

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

Name: Anonymous 2009-03-29 7:48

>>4
No really, read SICP.

Name: Anonymous 2009-03-29 7:50

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: Anonymous 2009-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: Anonymous 2009-03-29 7:55

SICP - The New Bible.

Name: Anonymous 2009-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: Anonymous 2009-03-29 8:03

Speaking of memes, hax my anux *grabs dick*.

Name: Anonymous 2009-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: Anonymous 2009-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: Anonymous 2009-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.

Name: Anonymous 2009-03-29 8:09

>>13
That post was bad and you should feel bad.

Name: Anonymous 2009-03-29 8:11

>>11

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.

Also, the page I'm referring to for the for loop is here:
http://docs.plt-scheme.org/guide/for.html

I was thinking about using for-each, but I was having trouble figuring out the syntax for it. But yeah, that example you gave is very helpful.

Name: Anonymous 2009-03-29 8:14

>>14
That post was sinful and you should repent.

Name: Anonymous 2009-03-29 11:15

Why don't you read chapter 1 of the guide ( http://docs.plt-scheme.org/guide/intro.html ) before going to chapter 11.

Name: Anonymous 2009-03-29 20:03

(map (lambda (x) [yourshit]) '(0 1 2 3 4))
How difficult is that.

Name: Anonymous 2011-02-03 4:16

Name: Anonymous 2013-08-31 22:09



           ,.へ,.へ -‐─- 、.,_
         ,. >、 `く       `' 、
       ., ' く_,.へ._> ,       ヽ、
       /    . '´  / l    ハ 、 ハ`フ   ___
      ,'   ,'   ,' /__'、   |/_|_ ハ  'r'     | r──┘ 
      l   / ,  .|/__」/_、 | _」/! }  }     | | l二二`l
      | ∠.イ|  「 l)l::}` \|´l:l!}|/ 八    | | く\/ /
      ',   八   'ひ-'    `"oイ ̄`   ; ;  > ,.く
       ',  /  l 、._,ゞ"      "}リ      く/ く/\>
       }     |  ト 、   ´   ,.イ!
       ノ    八 ', }  ーrァ升| |        r、 「l r、
   ト-‐''´    ,:' ,ハ ∨\ _ハ ヽ! |       くノ | /ゝ'
   `>'´   //´ヽレ'、|`}_アrr'7ハ |        / ' ー┐
  /    , '  '   ∨   ○ ∨!八      r'_イ.l三 l l
 ,: '     /    {    、   △  } |   ',       | l二 l |  
 {     ;    ∧    ヽ  × | |   ,.       └' ̄`┘
  、    、   ;  ',     \.八 '、!   }
  \    \ , く \   /`7ヽYヽ  ;     ___「l___
    )  ノ, /  `ア`' 、/ /__八,ハ}、/     | r‐┐r‐┐!
   (r'´ (, '     ./    ` ´ ヽ  ̄ ヽ.      | |_| |_| |
    `   {     ;         ',    ハ.     └‐ ┐r─┘
      ,-{ ` 、.,_、        ,     }        .|_|
    / ,r>、.,__ 、>-‐- 、.ノ  ノ    rノ、
     {_く_r、_,,.. -、_,.. -、_>イ__.>-く__r'

Name: Anonymous 2013-08-31 22:11

Did this guy ever finish his course?

Name: Anonymous 2013-08-31 22:14

maybe you didn't include the for module

Name: Anonymous 2013-08-31 23:41



       ∧/|  ∧、
    |ヽ!、ゝ,.r'ニ、ンi
    ゝ/ /    \
    _L...- '-───'-- ..,,_
   ,.へ ヽ - L = 」 -   /
  〈   ,.ゝ --─ri⌒ヽr--..,イ
。  γ´ ,'" _/__,.i   l |、!_i ト、 ゚
   i  ,'. / ,.-'、.ヽイノ,.-、i / i
 .o | レ イ.( (_)    () )イハノ  o
   .|. (| | |〃   ___ 〃l |.| 。
   |  /i | lゝ、  (  ) ,.イl.|.|
   |  ハ_l |.,-!`i ー-=.i´、i | |    O
O i イ_( ヽ.! | ヽ、iイ ン !/'),-、
  | iヽ、`'_,..-`つ ハ ヽ / つ _ゝ) ) )
  ', i(__,. - ''T´VYV (ゝ、_,..、_)
   ', ハ `.ーi´   (/  i_) `iーi´|
   V ヽ,.イ/ゝ、 __,.__,.__,.イヽン
    / / /       ヽ\

Name: Anonymous 2013-09-01 1:12



                、  ト、
                _)`y' .)_      /)
             ,. '"´ `      rO⌒O、   っ    ┌─────────┐
           /         ` ~=~ヽ       | 思  意   博   .こ |
           ,.' /  /   /       ヽ.  ':,      | わ  識  麗   ん |
    (\   /./   / -= /|   | =- |  ハ   ;     | な.  の  と.  な |
        ;' ;   ;'  __/ l|   ∧ __ ハ  |  |.    | か  差  守   に |
      ⊂.   | |    |ァ'´ァ'ヽ '、  .' ァ'ヽ`Y  !  !.     |  っ   が   矢.    |
        | |    l{. 弋zリ  \| 弋zリ ノl三!   |l     | た.  あ  で      |
        | 、  |l`//     '    //|--}.   |.     |   :   る          |
        |  \ '、_     , - 、   u |  |!   ;.     |   :   な          |
         ;!    `'ーヽ   (   )   ,.イ/)  ;     |   :   ん        .|
         /|  /   | >.、,    ,. イ (/|  ∧    |  ! !  て           |
        ;   , '    /  _r'| `" ´ ト、」__」/) /  '、    └─────────┘
       { /  __,rァ'"l|´ ム    /  |(/|__   ヽ、
        / ,.'´   |  |.   \/    |7 .ノ) `ヽ  ,ハ
     ./   |    」  |    /ム    |! (_イ   |  / |
     ,'   r‐ ''"´_]/ '  / {:::::::}ヽ  /レヘ/[`"'' ー┐ ;
      |   ; |‐''"´ /  ∨  「:::|  ∨   ', `"'' -|l (
     、 | |    7       |:::!       ∨     |  ヽ
      \/   |.      |:::|       |    ',  ノ
      r'_    、     _|:::|_      ノ      ヾ
     /     ヽ  `r   =-:|::::!:-=   イ  ァ'  ̄   \
    ,:'   ,r-/⌒ヽ. |      |::::|      .|  /⌒\- 、  ':,
    /  // 、\ン'}r     ヽ/     ム  {、/ ,  ヽ \ ハ

Name: Anonymous 2013-09-01 2:43



       _____      ,.-ァ
  _人_   >ヽ、>二ゝ< ニ>
  `Y´   ,.>-' _______ __`'<_   +
   + / ,.-‐''" ̄ ___ ̄`ヽ、ヽ.   ┼
    // /__!_/i ハ_!__ヽ.   Y'>
    i7 イイ _、V レ' 'に 'iヽハ  ハ  i`ー:ァ   _人_
    イ  ハイに!'   ゝ-' ' レヘ--‐'ァ' <   `Y´
    レヘ/ !'ゝ'   ___  "/|-‐ヘi  _,.イ _,.-‐へ/)-、
  _  <_从"  〈  _,!  ! |   |,,..-‐''"´   `r〈  ) i
 Σ'ヽ、  / |>.、.,___,. イレヘ!/V     _  !__!--‐'
 ゝ  (__Vレ'/三77-'くイ7ヽ!、  〉-‐'´ ̄   ̄
  ^ゝ、   ,ィ〈三//  }><{ i--‐'
    `^ 〈/⌒ヽi、  /   イ´
      r〈   Yj }><{   i    +
      Yゝ-イン〉'ゝ    イヽ、
 +    ヽ二/ /    ハ  \     _人_
     r/   /    /  ', /ヽ、   `Y´
    r〈            }><{  >、
    ヽ>、/         /  ,く/´
      ヽ>>、i___   }><{ __,イン
      .〉、二7ヽ>-<ンヘ__/',
     /:::::/        ';:::::::i
     i':::::7          ';::::::|
    /ト--i           /ーハ
    ヒ'⌒_)          (⌒ ,イ
     ̄            ` ̄´

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