[racket-users] Pixelated results from pict->bitmap

2017-07-13 Thread Philip McGrath
Bitmaps created using pict->bitmap look pixelated to me on screen (on Mac OS in "Retina" mode, which I suspect might be relevant). I initially discovered this when using picts as labels for message% instances like this: #lang racket/gui (require pict) (define f (new frame% [label

Re: [racket-users] Struggling with writing array generator function

2017-07-13 Thread Vasily Rybakov
Well, actually that will be nested vectors, I just used list as example. I thought about storing arrays as one-dimentional vectors, but it makes hard to work with literal arrays. If I use nested vectors, then I can write something like: (matrix-* A #[#[1 2 3] #[4 5 6]]) -- You received this

Re: [racket-users] Struggling with writing array generator function

2017-07-13 Thread Vasily Rybakov
Daniel, thank you for your response! It really helped. I've focuded too much on recursion and tried to put nested array generation into it, without realizing that I can use external loop. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To

Re: [racket-users] Struggling with writing array generator function

2017-07-13 Thread Daniel Prager
Hi Vasily Since you insist ... ;-) The main issue is how to reduce the number of args with each step of the recursion: looks like a job for curry! Here's one way to do it: (define (generate-array n f) (for/list ([i 3]) (if (= n 1) (f i) (generate-array (sub1 n) ((curry f)

Re: [racket-users] Struggling with writing array generator function

2017-07-13 Thread Neil Van Dyke
(If this is for a school assignment, and the following comments are confusing, please disregard them. The comments might make a school assignment harder than it's supposed to be.) Are you sure you want your n-dimensional arrays to be implemented as nested Racket lists? What about a

[racket-users] Re: Struggling with writing array generator function

2017-07-13 Thread Vasily Rybakov
My current approach is to try to make recursion that will expand into somethig like this (for generator functions that accepts 1, 2 and 3 arguments respectively): (define (bv func) (build-vector 3 func)) ((lambda (f) (bv (lambda (x) (f x generator) ((lambda (f) (bv

Re: [racket-users] Struggling with writing array generator function

2017-07-13 Thread Vasily Rybakov
On Thursday, July 13, 2017 at 9:30:44 PM UTC+2, Daniel Prager wrote: > It's straightforward to design a recursive macro with similar intent, but > different surface syntax: > > (generate-array (i) 10) > (generate-array (i) i) > (generate-array (i j) (+ (* 10 i) j)) > > > Dan Thanks for the

Re: [racket-users] Struggling with writing array generator function

2017-07-13 Thread Daniel Prager
It's straightforward to design a recursive macro with similar intent, but different surface syntax: (define-syntax generate-array (syntax-rules () [(_ (i) exp) (for/list ([i 3]) exp)] [(_ (i j...) exp) (for/list ([i 3]) (generate-array (j...) exp))])) (generate-array (i) 10)

[racket-users] Struggling with writing array generator function

2017-07-13 Thread Vasily Rybakov
I need to write function generete-array: (define (generate-array num-dimensions generator) ...) such that it generate num-dimensions array (each dimension is of size 3) and uses generator function to produce elements of array (generator accepts num-dimensions arguments and returns number;

Re: [racket-users] Running code at shutdown

2017-07-13 Thread Sam Tobin-Hochstadt
You probably want to look at http://docs.racket-lang.org/reference/Exiting.html for the exit-handler or executable-yield-handler, or for a more general system, plumbers: http://docs.racket-lang.org/reference/plumbers.html Sam On Thu, Jul 13, 2017 at 9:50 AM, David Storrs

[racket-users] Running code at shutdown

2017-07-13 Thread David Storrs
Short form: How can I define a block of code such that it will run immediately before the program ends? What I'm trying to achieve: Make my testing module (which is not rackunit) check whether or not the expected number of tests ran. I'd also like to know the answer to the 'run at program

Re: [racket-users] Questions on HtDP 2e, Ex. 356

2017-07-13 Thread Jens Axel Søgaard
> I hope this is heading in the right direction. Looks fine to me. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com.

Re: [racket-users] Re: Boot To Racket

2017-07-13 Thread Daniel Brunner
Hey, just to add another idea: > > Don't be scared away from coding your own Scheme from scratch. A whole > lot of them got started that way, because it's easy to code your own (If > you borrow existing approaches for garbage collection and evaluation > with tail calls), then do something