Re: [racket-users] Assigning actions to any key on a terminal

2017-12-09 Thread Rickard Andersson
> Hi, OK, I'll look for the console API, or installing Linux/BSD on a 
> virtual machine, or even go experiment with racket/gui, since it's just 
> a little project mostly for fun. :)
> 
> Greetings
> Cleverson
> 

`racket/gui` is amazing and works super well on Windows indeed, so I
would definitely recommend it even for small stuff. Windows doesn't have
a great CLI experience anyway, so running things in a GUI makes more
sense.

-- 
With regards,
Rickard Andersson

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Urgent Need--Cloud Engineer---EAD or GC or Citizens only

2016-09-12 Thread Rickard Andersson
I must have confused the racket ML with one of the other ones I'm on in 
terms of what can be posted.


I suppose it was a bit amusing and I'm just not in the state of mind for 
it. I apologize for any perceived ungratefulness, sorry.


On 12-Sep-16 20:00, John Clements wrote:

On Sep 12, 2016, at 9:54 AM, Rickard Andersson <rickard.m.anders...@gmail.com> 
wrote:

Why was this trash approved for posting?

Haven’t you heard that the Racket team is pivoting toward enterprise software 
develop integrationpatternscloudfoundryhibernatescripting?

:)

Seriously: we rely on Google to keep the spam out, and generally they do a 
pretty good job; I find the signal-to-noise ratio to be extremely high here. 
I’ve deleted this post and marked it as spam, if that helps.

Thanks for your note!

John Clements





--
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Urgent Need--Cloud Engineer---EAD or GC or Citizens only

2016-09-12 Thread Rickard Andersson

Why was this trash approved for posting?


On 12-Sep-16 19:45, Saikiran Nandrolu wrote:


Hi Friends,

Hope you are doing great,

I have an urgent requirement from one of my esteem client, I will 
appreciate if you can have an eye on the below requirement and send me 
your consultant updated profile ASAP.


*Title: Cloud Engineer*

*Location: Cincinnati, OH*

*Duration: 12 months + (Strong potential for extension)*

*EAD or GC or Citizens only***

**

**Top Desired Skills: Pivotal Cloud Foundry or Open Source Cloud 
Foundry, Docker experience**


*Pivotal Cloud Foundry or Open Source Cloud Foundry experience.**
*2) Docker experience.*
**3) Must be comfortable with not working with AWS and not complaining 
about not working with AWS.*

*4) Someone hands on, a doer versus a thinker.*

*Desired Skills:*

*1)**Experience with scripting and automation languages and tools 
(bash, curl, PowerShell, Chef/Puppet/Ansible, Python, Ruby, 
JavaScript, etc). *


*2)**Experience with enterprise software develop integration patterns, 
frameworks and tools (Java EE, Spring Framework, Spring Cloud, Spring 
Configuration, Spring Boot, Hibernate, Spring AOP, Spring MVC, Ruby, 
JavaScript, REST, JSON, HTML). *


*3)**AngularJS (SPA), SQL, Teamcity/Jenkins, GIT/Stash, IntellijIDEA, 
Eclipse, etc). *


Best Regard

Sai Kiran

saikir...@usmsystems.com 

703-880-4146

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

For more options, visit https://groups.google.com/d/optout.


--
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] What do you use macros for?

2016-04-07 Thread Rickard Andersson
> What have you used them for?

While it's certainly not the most impactful macro in the world, I was
pretty pleased with being able to do this:

https://github.com/GoNZooo/gonz/blob/master/gonz/define-test.rkt

It's a macro that allows me to bundle expected inputs with expected
outputs for those inputs together with a contract definition, meaning
I have a tighter coupling of test-cases together with definitions of
functions without a bunch of `(module+ test ...)`.

> What do they do that a function couldn't?

In this case we're actually generating the `(module+ test ...)` entries
based on the lists inside the macro, but then simply appending these to
our generated code, meaning they won't be defined in a function (which
they can't), but rather added as if we were doing it manually.

The manual variant for the first example in this file would look as
follows:

(define/contract (square x)
  (integer? . -> . integer?)
  (expt x 2))

(module+ test
  (check-equal? (square 2) 4)
  (check-equal? (square 3) 9)
  (check-equal? (square 5) 25))

We're skipping straight to defining inputs and outputs, only because we
are using macros.

> What are good times to use them

In this case I wanted to succinctly define test cases for functions and
for this to be tighter coupled to function definitions, but you can't
call `module+` while inside a function, so the only real solution is to
lift that content outside the function definition.

> ... what are their drawbacks?

The obvious drawback here is that this macro is next to useless for
anyone else when they stumble upon it. When you have an actually useful
macro (I hesitate to call this one universally useful, though I like it
myself), this is solved by great documentation facilities, like
Scribble, as well as good macro constructs that will help you guide your
user through proper usage.

On Wed, Apr 06, 2016 at 05:19:05PM -0700, David Storrs wrote:
> Hi folks,
> 
> Macros are one of the biggest features that people list as the advantages
> of LISP / Scheme, and I don't really understand them.  I get the basics --
> they can create new code structures -- but not the implications  What have
> you used them for, and what do they do that a function couldn't?  What are
> good times to use them, and what are their drawbacks?
> 
> Dave
> 
> -- 
> 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.
> For more options, visit https://groups.google.com/d/optout.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Sending post and get using DrRacket

2015-12-05 Thread Rickard Andersson
Hi, Hector.

The following should be what you are looking for in terms of sending a POST
request:

http://pasterack.org/pastes/86127

You can find more information on `http-sendrecv` and its related functions
here:

http://docs.racket-lang.org/net/http-client.html?q=http-sendrecv#%28def._%28%28lib._net%2Fhttp-client..rkt%29._http-sendrecv%29%29

`http-sendrecv/url` is here, in the net/url library:

http://docs.racket-lang.org/net/url.html?q=http-sendrecv#%28def._%28%28lib._net%2Furl..rkt%29._http-sendrecv%2Furl%29%29

// Rickard


On Sun, Dec 6, 2015 at 6:40 AM, Hector Fabio Jimenez Saldarriaga <
hfjime...@utp.edu.co> wrote:

> Hi everybody,
>
> Recently I'm working in my first application using DrRacket, The
> application is specifically a simple and nice video game( it calls Space
> Invaders), I would like to add a simple function to send a post or maybe
> get request. When the user uses all his lifes it's going to be game over,
> after that I want to take the score points and the username and send it to
> a small application in nodejs. The next figure shows how it would be :
>
> Just in case that you don't want to download the attached file please open
> the next url in imgur.
>
> http://imgur.com/oTTHtsM
>
> It is posible to implement something like this ?, Because i'm checking the
> drracket documentation and I'm stucked here :(, please help me giving me
> options or examples to do this.
>
> Thanks in advanced,
> Sincerely
> Hector F.
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Official Docker images for Racket

2015-09-02 Thread Rickard Andersson
I've previously tried to minimize the build without any success, so if you 
can make a base image using only busybox or alpine linux without any 
problems that'd obviously be preferable.


On Wed, 2 Sep 2015, Asumu Takikawa wrote:


On 2015-09-02 15:35:25 -0700, Jack Firth wrote:

I do a lot of Racket development in Docker, and it's a pretty big pain.
There's a handful of images on Docker Hub but they're pretty unmaintained,
usually lag behind a version or two, tend to be built off an unnecessarily
large base image like ubuntu, don't offer a snapshot build, and don't offer
"minimal Racket" versions. I'd like to work on this and add some Racket
images to the Official images like other languages have. Has anyone else
worked on this?


That sounds great and if you put Racket images up I would happily use them.

I did look into building images on Dockerhub a while ago and had trouble
getting builds to finish (ran out of memory), but it looks like they have
improved the infrastructure since then.

Cheers,
Asumu

--
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.
For more options, visit https://groups.google.com/d/optout.



--
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] `divides?` from math/number-theory slow?

2015-08-24 Thread Rickard Andersson
The above is of course supposed to say that `divides?` needed a few seconds
more than the modulo example even in Typed Racket. Both were of course
typed when running with TR.

On Mon, Aug 24, 2015 at 3:38 PM, Rickard Andersson 
rickard.m.anders...@gmail.com wrote:

 Yes, that indeed seems to be the problem. However, even after managing to
 wrap the types properly, using `divides?` still ended up being a bit
 slower. Not dramatically slower, but still noticably and unexpectedly.

 As I'm not at all comfortable with Typed Racket I would appreciate if
 someone could show how one would annotate the example minimally to give the
 optimizer enough information to surpass Racket. As of this moment I haven't
 really managed to see any improvement from using Typed Racket. It cut down
 the time `divides?` needed to a few seconds more than Racket. Otherwise, it
 had no effect (on the other example either).

 As a point of curiosity; I had to work around the fact that apparently
 there were not enough type annotations by wrapping the `for`s in functions
 and typing them accordingly. Is there a better way to do this?

 I'm currently trying to compare some performance between OCaml, C and
 Racket and I'm currently using the aforementioned example.

 Here are some timings:

 | time racket divides.rkt; time ./divides_c; time ./divides_ocaml
 416658333
 racket divides.rkt  7.32s user 0.02s system 100% cpu 7.336 total
 416658333
 ./divides_c  0.49s user 0.00s system 99% cpu 0.488 total
 416658333
 ./divides_ocaml  0.75s user 0.00s system 99% cpu

 The idea is to see how fast one can make the following:

 #lang racket/base

 (define (divisible-by? x d)
   (= (modulo x d)
  0))

 (module+ main
   (for/sum ([x (in-range 3 5)])
 (if (x . divisible-by? . 3)
   x
   0))
   )

 On Mon, 24 Aug 2015, Pierpaolo Bernardi wrote:

 On Mon, Aug 24, 2015 at 1:25 PM, Jens Axel Søgaard
 jensa...@soegaard.net wrote:

  It looks very odd to me.


 Maybe this is due to calling TR functions from plain Racket?



-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] `divides?` from math/number-theory slow?

2015-08-24 Thread Rickard Andersson
With regards to the measurements; as is obvious from this mailchain, I 
know about and use the `time` form. It hasn't skewed the results.


Using the optimizing coach in DrRacket has yielded no results, really. I 
tried using it and there wasn't any advice on what to do for speedups 
(unless that advice isn't very discoverable, I don't know.).


The only meaningful difference I discovered for TR was using 6.1.1, as 
apparently there was an optimization that'd been borked for 6.2.0 and 
onwards.


I'm still curious about speed-ups with TR. I had expected it to perform 
better than Racket, but I guess the big win is that you get contracts with 
better performance instead of much faster, brittle code?


On Mon, 24 Aug 2015, Vincent St-Amour wrote:


On Mon, 24 Aug 2015 08:38:46 -0400,
Rickard Andersson wrote:


Yes, that indeed seems to be the problem. However, even after managing
to wrap the types properly, using `divides?` still ended up being a bit
slower. Not dramatically slower, but still noticably and unexpectedly.

As I'm not at all comfortable with Typed Racket I would appreciate if
someone could show how one would annotate the example minimally to give
the optimizer enough information to surpass Racket. As of this moment I
haven't really managed to see any improvement from using Typed
Racket. It cut down the time `divides?` needed to a few seconds more
than Racket. Otherwise, it had no effect (on the other example either).


In general, if you want to ensure that your code plays nice with the
Typed Racket optimizer, I recommend you try the optimization coach, in
DrRacket. There should be a button in the toolbar when you're working in
Typed Racket. The coach points out portions of your programs where
additional optimizations could apply if you were to change your program
a bit, and give you advice on how to change it.

The Typed Racket guide also has some general performance advice:

   http://docs.racket-lang.org/ts-guide/optimization.html



As a point of curiosity; I had to work around the fact that apparently
there were not enough type annotations by wrapping the `for`s in
functions
and typing them accordingly. Is there a better way to do this?


Have you tried adding annotations to the `for` forms directly? The docs
show the syntax:

   
http://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._for%29%29



I'm currently trying to compare some performance between OCaml, C and
Racket and I'm currently using the aforementioned example.

Here are some timings:

| time racket divides.rkt; time ./divides_c; time ./divides_ocaml
416658333
racket divides.rkt  7.32s user 0.02s system 100% cpu 7.336 total
416658333
./divides_c  0.49s user 0.00s system 99% cpu 0.488 total
416658333
./divides_ocaml  0.75s user 0.00s system 99% cpu

The idea is to see how fast one can make the following:

#lang racket/base

(define (divisible-by? x d)
  (= (modulo x d)
 0))

(module+ main
  (for/sum ([x (in-range 3 5)])
(if (x . divisible-by? . 3)
  x
  0))
  )


In this particular example, you may get speedups by using Typed Racket's
sub-`Integer` types, such as `Index` or `Fixnum`. These can guarantee to
the typechecker that your code will not generate bignums, which will
allow TR to optimize accordingly.

A note on your particular measurement methodology. When you use unix's
`time` command on `racket x.rkt`, this measures not only the actual
execution time, but also compilation to bytecode and, in the case of
Typed Racket programs, typechecking time as well (which can be
significant). If you run `raco make x.rkt` before measuring, you avoid
measuring that extra overhead. If you also want to avoid measuring the
startup overhead of the Racket VM (which only really matters for short
scripts), you should use the `time` form in Racket, instead of the unix
`time` command.

Vincent



--
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] `divides?` from math/number-theory slow?

2015-08-24 Thread Rickard Andersson
I was very curious about what you were talking about, as I saw wildly 
different numbers (in line with what I'd seen before).


However, I did the following test:

| ~/tools/racket/6.1.1/bin/racket typed_divide.rkt
cpu time: 536 real time: 537 gc time: 27
cpu time: 347 real time: 347 gc time: 4
cpu time: 87 real time: 84 gc time: 0

| ~/tools/racket/6.2.0/bin/racket typed_divide.rkt
cpu time: 567 real time: 565 gc time: 10
cpu time: 960 real time: 958 gc time: 13
cpu time: 83 real time: 84 gc time: 0

| ~/tools/racket/6.2.1/bin/racket typed_divide.rkt
cpu time: 600 real time: 601 gc time: 70
cpu time: 970 real time: 974 gc time: 23
cpu time: 86 real time: 85 gc time: 0

The below program is what's being run:

#lang racket/base

(module t typed/racket/base
  (: divides? : Integer Integer - Boolean)
  (define (divides? a b)
(cond
  [(zero? a)  #f]
  [else  (= (remainder b a) 0)]))
  (provide divides?))

(module c racket/base
  (require racket/contract/base)
  (define (divides? a b)
(cond [(zero? a)  #f]
  [else  (= (remainder b a) 0)]))
  (provide
(contract-out
  [divides? (- exact-integer? exact-integer? boolean?)])))

(module no-contract racket/base
  (define (divides? a b)
(cond
  [(zero? a)
   #f]
  [else
(= (remainder b a) 0)]))
  (provide divides?))

(require (prefix-in with-contract: (submod . c)))
(require (prefix-in typed: (submod . t)))
(require (prefix-in no-contract: (submod . no-contract)))

(time
  (for ([x (in-range 3 500)])
(if (3 . with-contract:divides? . x)
  x
  0)))

(time
  (for ([x (in-range 3 500)])
(if (3 . typed:divides? . x)
  x
  0)))

(time
  (for ([x (in-range 3 500)])
(if (3 . no-contract:divides? . x)
  x
  0)))


On Mon, 24 Aug 2015, Robby Findler wrote:


My message below is not doing the right test. This is the right test
and it produces the expected result, namely that the TR version runs a
bit faster (presumably because of type-based optimizations that TR
does).

Robby

#lang racket

(module t typed/racket/base
 (: divides? : Integer Integer - Boolean)
 (define (divides? a b)
   (cond [(zero? a)  #f]
 [else  (= (remainder b a) 0)]))
 (provide divides?))

(module c racket/base
 (require racket/contract/base)
 (define (divides? a b)
   (cond [(zero? a)  #f]
 [else  (= (remainder b a) 0)]))
 (provide
  (contract-out
   [divides? (- exact-integer? exact-integer? boolean?)])))

(require (prefix-in c: (submod . c)))
(require (prefix-in t: (submod . t)))

(time
(for ([x (in-range 3 500)])
  (if (3 . c:divides? . x)
  x
  0)))

(time
(for ([x (in-range 3 500)])
  (if (3 . t:divides? . x)
  x
  0)))


On Mon, Aug 24, 2015 at 8:18 AM, Robby Findler
ro...@eecs.northwestern.edu wrote:

It looks to me like the slowdown isn't entirely explained by contract
checking, or perhaps TR isn't generating the contracts I would have
guessed. With the program below, I see this output

cpu time: 1228 real time: 1228 gc time: 133
cpu time: 658 real time: 658 gc time: 18
cpu time: 80 real time: 81 gc time: 0

but would have expected the first two lines to be nearly the same.

Robby

#lang racket

(require (only-in math/number-theory divides?))

(define (divisible-by? x d)
  (= (modulo x d)
 0))

(module d racket/base
  (require racket/contract/base)
  (define (divisible-by? x d)
(= (modulo x d)
   0))
  (provide
   (contract-out
[divisible-by? (- exact-integer? exact-integer? boolean?)])))

(require (prefix-in c: (submod . d)))


(module+ main
  (time
   (for ([x (in-range 3 500)])
 (if (3 . divides? . x)
 x
 0)))

  (time
   (for ([x (in-range 3 500)])
 (if (3 . c:divisible-by? . x)
 x
 0)))

  (time
   (for ([x (in-range 3 500)])
 (if (x . divisible-by? . 3)
 x
 0




--
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.
For more options, visit https://groups.google.com/d/optout.


RE: [racket-users] Re: My son's game in Racket

2015-08-24 Thread Rickard Andersson
I don't know how much you involve yourself in the actual making of things 
(it might be a principle of yours to leave everything practical to your 
son and to only help with concepts), but couldn't it be useful to simply 
make a macro like a `(place-images* ([imag1 x y] ...))` or the like? Maybe 
it's one of those now you have two problems! type of situations and not 
suitable for the context, I don't know.


On Mon, 24 Aug 2015, John Carmack wrote:


The idea that you functionally compose images like this:

(place-image image-1 x y
(place-image image-2 x y
(place-image image-3 x y)))

Which draws image1 on top of image2 on top of image 3, which is backwards from the 
painters order that would draw image 3, then image 2, then image 1.

This imperative, side-effect-ing code is a little less clear to a beginner with 
the OOP and DC concepts, but It better represents what actually happens, and it 
is much easier to modify the code without worrying about the nesting.

(send dc draw-bitmap imag3 x y)
(send dc draw-bitmap imag2 x y)
(send dc draw-bitmap imag1 x y)

-Original Message-
From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com] On 
Behalf Of David Grenier
Sent: Monday, August 24, 2015 1:14 PM
To: Racket Users
Cc: John Carmack
Subject: [racket-users] Re: My son's game in Racket

On Monday, August 24, 2015 at 12:28:07 PM UTC-4, John Carmack wrote:

We “released” my 10 year old son’s game that was done in Racket:
www.1k3c.com

 

I’m still taking a little heat from my wife for using an obscure
language instead of something mainstream that is broadly used in industry, but 
I have nothing but good things to say about using Racket and DrRacket for a 
beginning programmer,  and highly recommend it.

 

I can’t recommend 2htdp/universe for this sort of thing, though.  I
had to drop to the native GUI bitmaps for performance reasons, hack around the 
lifecycle to support a separate editor window, and I still don’t know how to 
make the Quit  menu item actually exit the app on the Mac version.

 

I completely understand the reasoning for the way 2htdp/universe is
built, and saying that a “real” project should use the grown-up APIs is fine, 
but the evolution from making a little animation to controlling it somehow to 
fleshing it  out into a game is so natural that recommending a fairly big 
rewrite is unfortunate.

 

I’m a big booster of functional programming, but I’m not sure that the
functional drawing paradigm ever really sank in while my son was working with 
it, rather it felt like you just drew everything backwards with missing 
parenthesis at  the end.  I suspect that using the standard imperative GUI 
drawing code will make perfect sense to him.

 

I’m not sure yet if we are going to migrate to the regular GUI code for 
upcoming work, or jump all the way to OpenGL so he can learn the joys of “Why 
is the screen all black?”

 


Not clear what was meant both times you wrote backwards are you referring to 
the lisp-style function call? Something that could be alleviated by say F#'s pipe forward 
operator?

let (|) a f = f a

or Clojure's - macro?

--
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.
For more options, visit 
https://urldefense.proofpoint.com/v1/url?u=https://groups.google.com/d/optoutk=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0Ar=Kjg6LltY9QjkipKooaVldA%3D%3D%0Am=HArZE0M9OqU4wspKLzQzG6N5gO9ncSxPP9qVzkUgoVU%3D%0As=b451faca736dc42c554f148983e7279865ef32be9ddf2df75f5c88c15dd34a73.

--
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.
For more options, visit https://groups.google.com/d/optout.



--
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] `divides?` from math/number-theory slow?

2015-08-24 Thread Rickard Andersson

Hi,

I noticed that the `divides?` function from math/number-theory seems to be 
a huge bottleneck for whatever reason.


This seems strange to me, but I figured I'd write to the list to see if 
maybe there are trade-offs made that make sense mostly for big integers or 
something.


Example with (time):

#lang racket/base

(require (only-in math/number-theory divides?))

(define (divisible-by? x d)
  (= (modulo x d)
 0))

(module+ main
  (time
(for/sum ([x (in-range 3 5)])
  (if (3 . divides? . x)
x
0))) ; cpu time: 96257 real time: 96166 gc time: 128
  (time
(for/sum ([x (in-range 3 5)])
  (if (x . divisible-by? . 3)
x
0))) ; cpu time: 7277 real time: 7266 gc time: 0
  )

--
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] About redrawing buttons on-demand in gui framework

2015-07-23 Thread Rickard Andersson

Hi, David.

Perhaps I was unclear in my description, but as you guessed anyway, I 
meant that the geometry of the button wasn't being affected by a 
set-label method call.


This is precisely what I was looking for. Thank you very much for your 
help. :)


// Rickard Andersson.

On Thu, 23 Jul 2015, David T. Pierson wrote:


On Tue, Jul 21, 2015 at 10:15:40PM +0300, Rickard Andersson wrote:

Initially, I assumed that a set-label call for a button, for example, would
redraw that button automatically, with the new dimensions and everything in
mind.

When that wasn't the case, I looked for ways to force a redraw of the


I assume you mean the button isn't being resized.  (If instead you mean
the new label does not appear at all, then that's a different problem
which this email does not address.)

I was able to get a resize to occur by recalculating the minimum
dimensions and setting them via the min-width and min-height methods.
I figured this out by examing the do-auto-resize function in message%,
so I assume it is close to being an appropriate solution.

Here is the (not extensively tested) code.  Note this code assumes the
label is always a string (not a bitmap) and assumes that the font is
always normal-control-font.

(define auto-resizable-button%
 (class button%
   ;; A control's minimum graphical size is set at instantiation
   ;; time and can never be made smaller.  See:
   ;; 
http://docs.racket-lang.org/gui/windowing-overview.html#%28tech._graphical._minimum._width%29
   ;; Therefore set the initial label to  so it can later be
   ;; resized as small as necessary.
   (init label)
   (super-new [label ])
   (send this set-label label)
   ;; Override set-label to recalculate the new minimum dimensions.
   ;; Note this assumes that the label is always a string, and also
   ;; assumes the font in use is the default normal-control-font.
   (define/override (set-label new-text)
 (define old-text (send this get-label))
 (define old-min-w (send this min-width))
 (define old-min-h (send this min-height))
 (define-values (old-txt-w old-txt-h)
   (get-window-text-extent old-text normal-control-font #t))
 (define-values (new-txt-w new-txt-h)
   (get-window-text-extent new-text normal-control-font #t))
 (define extra-w (- old-min-w old-txt-w))
 (define extra-h (- old-min-h old-txt-h))
 (super set-label new-text)
 (send this min-width (+ new-txt-w extra-w))
 (send this min-height (+ new-txt-h extra-h)

David



--
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] About redrawing buttons on-demand in gui framework

2015-07-21 Thread Rickard Andersson

Hi, everyone.

I've stumbled upon some unforeseen strangeness regarding the redrawing of 
certain elements in the GUI framework recently.


Initially, I assumed that a set-label call for a button, for example, 
would redraw that button automatically, with the new dimensions and 
everything in mind.


When that wasn't the case, I looked for ways to force a redraw of the 
button, but the only things I could find were reflow-container and the 
associated methods. They only seem to apply to containers, however, and 
won't actually redraw the buttons in those containers.


The ugly hack that I had to settle on in lieu of finding a better choice 
is to just recreate the buttons on demand, but this brought a lot of 
baggage in terms of having to make sure all references still point to the 
button, etc., so I would've liked to have a version that simply redraws 
the exact same object with another label.


Any help is appreciated, as I'd like to avoid these changes becoming too 
ingrained in my code.


// Rickard Andersson

--
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Are there any BDD testing frameworks for Racket?

2015-07-12 Thread Rickard Andersson
I would encourage you to release this no matter the situation in this 
thread, Jack, as it sounds very interesting.


On Sun, 12 Jul 2015, Jack Firth wrote:


Out of curiosity, what are you looking to test? If it's an HTTP api, I've got a 
ton of useful testing tools for that that I was just thinking of making into a 
package.

--
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.
For more options, visit https://groups.google.com/d/optout.



--
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Overriding on-subwindow-event for message%

2015-07-09 Thread Rickard Andersson

Hi, everyone.

I was trying to override on-subwindow-event for message% in the following 
way:


(define mousable-message%
 (class message%

  (define/override
   (on-subwindow-event receiver event)

   (printf Event ~a @ ~a~n
(send event get-event-type)
receiver))

  (super-new)))

This, however, doesn't seem to work. Is there anything special about
message% that makes it so that it shouldn't be overridden? This works
fine for buttons and the purpose is to be able to move the UI components
around with certain mouse events.

// Rickard Andersson

--
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] help please on git/github pull request

2015-07-03 Thread Rickard Andersson
I think if there is a direction to go in, it's to make a SSH-friendly and 
truly extensible text version of DrRacket. I would use this all day; I 
only really use vim because it's terminal friendly and the editing is 
great.


DrRacket offers a lot in terms of integration with Racket facilities and I 
would rather have a text version of that than more Emacs/vim.


On Fri, 3 Jul 2015, Tim Brown wrote:


Thanks for the help folks!

I'll take a long hard look at rebasing before I do anything.
It sounds like something my mother would have advised against.

On 03/07/15 03:52, Alexander D. Knauth wrote:

 On Jul 2, 2015, at 1:53 PM, John Clements cleme...@brinckerhoff.org
 wrote:
   On Jul 2, 2015, at 7:31 AM, Alexander D. Knauth alexan...@knauth.org 
   wrote:
   After you resolve them you will (I think) need to `git add` the files 
   that you resolved conflicts for, then
   `git rebase --continue`, and then when the rebase is finished, `git 
   push -f origin topic-branch`.
 
  Also, I think you eventually want to get things back onto the

  master branch, right? After rebasing, you should be able to check
  out masteragain, then do a
 
  git merge —ff-only topic-branch
 
  at which point you should be able to push cleanly.


 Um, I'm going by Greg Hendershott's advice in his guide for
 infrequent contributors to Racket, but
 wouldn't you not want to do that, because that would mess up the
 master branch and make it a dirty fork?



 
http://www.greghendershott.com/2013/04/a-guide-for-infrequent-contributors-to-racket.html#waiting-is-the-hardest-part


I'm trying to follow that. I think it's not designed for someone who
makes a tweak, is sent down the pit for a month and THEN tries to merge
back into a later master.

  In the meantime, you might be tempted to merge your topic branch into 
  your own master. Don’t!
 
  If you were to do that, your master would cease being a nice clean

  mirror of the upstream master. Remember how no one likes a dirty
  fork, so we’re diligently using git pull --ff-only upstream
  master?


That's been well drilled into my (mostly by Greg's doc). Which is why
I'm asking before doing anything!

Tim

--
Tim Brown CEng MBCS tim.br...@cityc.co.uk

City Computing Limited · www.cityc.co.uk
 City House · Sutton Park Rd · Sutton · Surrey · SM1 2AE · GB
   T:+44 20 8770 2110 · F:+44 20 8770 2130

City Computing Limited registered in London No:1767817.
Registered Office: City House, Sutton Park Road, Sutton, Surrey, SM1 2AE
VAT No: GB 918 4680 96

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

For more options, visit https://groups.google.com/d/optout.



--
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Emacs Lisp as a Racket Language?

2015-07-03 Thread Rickard Andersson
I think if there is a direction to go in, it's to make a SSH-friendly and 
truly extensible text version of DrRacket. I would use this all day; I 
only really use vim because it's terminal friendly and the editing is 
great.


DrRacket offers a lot in terms of integration with Racket facilities and I 
would rather have a text version of that than more Emacs/vim.



On Fri, 3 Jul 2015, Michael Titke wrote:


On 02/07/2015 21:36, Greg Davidson wrote:

 Is there interest in creating a Gnu Emacs Lisp Racket Language, along with
 the underlying APIs (perhaps tied to DrRacket) sufficient to compile and
 run Gnu Emacs Lisp extension packages?  Is there prior or ongoing work for
 such a project?

 For some years there has been an attempt to port Gnu Emacs to run under
 Guile Scheme.  A big stumbling block is the vast amount of extensions
 written in Emacs Lisp and continuing development thereof.  Racket seems to
 be a *much* better platform for such a project than Guile, don't you
 think?

 _Greg (a long-time ambivalent Emacs user tired of Emacs Lisp)



I don't think elisp makes much sense out of Emacs. There is nothing special 
about it as a programming language: it's Lisp (and not Scheme) and depends on 
primitives of a text editor frame work from the 80s. Porting individual 
modes or features to Dr Racket (or even Viper/VSI) might give better results 
then reimplementing the intrinsics of the overall Emacs package. But that 
depends on the expectations and intentions of the programming users.


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

For more options, visit https://groups.google.com/d/optout.




--
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.
For more options, visit https://groups.google.com/d/optout.