Re: [racket-users] How to apply side effects to all elements in a list

2017-03-22 Thread Matthias Felleisen
Yes! John just taught you how to fish. > On Mar 22, 2017, at 3:51 PM, 'John Clements' via Racket Users > wrote: > > >> On Mar 22, 2017, at 12:45 PM, Angus wrote: >> >> I am a bit stuck on rendering images in a list. >> >> Here is my code below. >> >> (require 2htdp/image) >> >> (define

Re: [racket-users] How to apply side effects to all elements in a list

2017-03-22 Thread Daniel Prager
Hi Angus Usually it helps to start by getting something simple to work and then little-by-little adding more. E.g. Here's a working example with squares instead of bears, and limited to just varying rotation ... #lang racket (require 2htdp/image) (define blue-square (square 25 'solid 'blue))

Re: [racket-users] How to apply side effects to all elements in a list

2017-03-22 Thread Alex Knauth
> On Mar 22, 2017, at 12:51 PM, 'John Clements' via Racket Users > wrote: > >> On Mar 22, 2017, at 12:45 PM, Angus wrote: >> >> render-bear works but I can't get render-bears to work. What am I doing >> wrong? Any hints? > > Rendering bears is quite dangerous. I’m surprised you got even on

Re: [racket-users] How to apply side effects to all elements in a list

2017-03-22 Thread Sam Caldwell
2thdp/image isn't effectful; images are values. You need to combine the image you get from rendering one bear with the image you get from rendering the rest of the list. You can do so using one of the combiners provided by the library: (combiner-of-choice (render-bear (first bears))

Re: [racket-users] How to apply side effects to all elements in a list

2017-03-22 Thread 'John Clements' via Racket Users
> On Mar 22, 2017, at 12:45 PM, Angus wrote: > > I am a bit stuck on rendering images in a list. > > Here is my code below. > > (require 2htdp/image) > > (define-struct bear-state (x y rotation size)) > > (define MTS (empty-scene WIDTH HEIGHT)) > > BEAR-IMAGE is just a graphic - of a bear.

[racket-users] How to apply side effects to all elements in a list

2017-03-22 Thread Angus
I am a bit stuck on rendering images in a list. Here is my code below. (require 2htdp/image) (define-struct bear-state (x y rotation size)) (define MTS (empty-scene WIDTH HEIGHT)) BEAR-IMAGE is just a graphic - of a bear. (define (render-bear b) (place-image (scale (bear-state-size b) (rota