[racket-users] do loops

2016-02-14 Thread JJ
I try to fill a binary tree with 5 random numbers, avoiding duplicates. Is 
there a more elegant way than this (using "Iterations and Comprehensions")?

(define tree4
  (do ([x (random 10) (random 10)]
   [c #f (contains? tree x)]
   [tree null (if c tree (insert tree x))]
   [i 0 (if c i (add1 i))])
[(>= i 5) tree]))

Thanks!

-- 
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] Re: how to transform syntax post-expansion?

2016-02-14 Thread Nota Poin
On Monday, February 15, 2016 at 4:07:53 AM UTC, Nota Poin wrote:
> (define-syntax (transform-post-expansion stx)
>   (syntax-case (expand stx) ()
> (...)))

Right, expand the syntax to expand the syntax... that'll work out great...

-- 
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] Re: how to transform syntax post-expansion?

2016-02-14 Thread Nota Poin
I suppose I could do something like this:

(define-syntax (transform-post-expansion stx)
  (syntax-case (expand stx) ()
(...)))

-- 
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] how to transform syntax post-expansion?

2016-02-14 Thread Nota Poin
I was trying to transform the syntax produced by an (include/...) statement, 
specifically (include/text) from scribble/text. But when I did this:
(transform (include "somefile.scribble")) it transformed the syntax #'(include 
"somefile.scribble"), not the syntax produced from its expansion.

I'm really hoping I don't have to do this:

(eval #`(transform #,@(include/text "somefile.scribble"))

Should I do like... (transform (expand (include/text "somefile.scribble"))) 
or... how would I transform what some syntax expanded into, rather than what it 
started out as?

-- 
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] DrRacket Coverage

2016-02-14 Thread Gustavo Massaccesi
I guess painting everything black is more confusing, because black is
used to mark the uncovered parts. The students will think that
everything is wrong.

I think that a better possibility is to add a backcolor (and
forecolor) to the code covered by the test. I vote for very light
green,  #C0FFC0, because green usually means ok. So each time they add
more test, they will get more green background until everything is
green.

Gustavo

On Sun, Feb 14, 2016 at 7:25 PM, Robby Findler
 wrote:
> Since in that context test coverage is an opt-in kind of a thing,
> maybe it makes sense to just make the whole thing turn black? Do you
> think that would also solve the problem?
>
> Robby
>
>
> On Sun, Feb 14, 2016 at 4:10 PM, Eli Barzilay  wrote:
>> On Sun, Feb 14, 2016 at 5:06 PM, Robby Findler
>>  wrote:
>>> Can you explain the use case a little bit more, please? This is the
>>> *SL languages?
>>
>> No, a plain #lang with the syntactic code coverage enabled.
>>
>>
>>> They run their program, they see black/orange, they add tests, they no
>>> longer see black/orange, and they are confused?
>>
>> Yes exactly -- and that's after I mention it in class and describe it in
>> the course pages.
>>
>>
>>> Did they not understand what black/orange means or were they expecting
>>> entirely black?
>>
>> I think that by the time they work hard to cover everything and the
>> coverage colors disappear they quickly jump to a conclusion that
>> something is wrong.  -- I even have the server report to them about
>> uncovered code, but even that doesn't help.
>>
>> In case it wasn't clear -- this is not too important, just something
>> that strikes me as weird every time another student gets confused.
>>
>> --
>> ((x=>x(x))(x=>x(x)))   Eli Barzilay:
>> http://barzilay.org/   Maze is Life!
>
> --
> 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] DrRacket Coverage

2016-02-14 Thread Robby Findler
Can you explain the use case a little bit more, please? This is the
*SL languages? They run their program, they see black/orange, they add
tests, they no longer see black/orange, and they are confused? Did
they not understand what black/orange means or were they expecting
entirely black?

Robby


On Sun, Feb 14, 2016 at 12:09 PM, Eli Barzilay  wrote:
> Every semester there are always students that think that DrRacket is
> broken when they add tests and the coverage colors go away.  I now tell
> them about it in advance (in class and in text), but it's still
> confusing people.
>
> So in the spirit of phone apps which teach you about themselves, how
> about something like a dialog popping up when coverage is enabled, and
> there is a non-trivial program, and there's complete coverage.
> Something like a short explanation of how the colors are the same since
> your code is completely covered, with a "got it" button to dismiss it.
>
> --
> ((x=>x(x))(x=>x(x)))   Eli Barzilay:
> http://barzilay.org/   Maze is Life!
>
> --
> 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] DrRacket Coverage

2016-02-14 Thread Robby Findler
Since in that context test coverage is an opt-in kind of a thing,
maybe it makes sense to just make the whole thing turn black? Do you
think that would also solve the problem?

Robby


On Sun, Feb 14, 2016 at 4:10 PM, Eli Barzilay  wrote:
> On Sun, Feb 14, 2016 at 5:06 PM, Robby Findler
>  wrote:
>> Can you explain the use case a little bit more, please? This is the
>> *SL languages?
>
> No, a plain #lang with the syntactic code coverage enabled.
>
>
>> They run their program, they see black/orange, they add tests, they no
>> longer see black/orange, and they are confused?
>
> Yes exactly -- and that's after I mention it in class and describe it in
> the course pages.
>
>
>> Did they not understand what black/orange means or were they expecting
>> entirely black?
>
> I think that by the time they work hard to cover everything and the
> coverage colors disappear they quickly jump to a conclusion that
> something is wrong.  -- I even have the server report to them about
> uncovered code, but even that doesn't help.
>
> In case it wasn't clear -- this is not too important, just something
> that strikes me as weird every time another student gets confused.
>
> --
> ((x=>x(x))(x=>x(x)))   Eli Barzilay:
> http://barzilay.org/   Maze is Life!

-- 
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] DrRacket Coverage

2016-02-14 Thread Eli Barzilay
On Sun, Feb 14, 2016 at 5:06 PM, Robby Findler
 wrote:
> Can you explain the use case a little bit more, please? This is the
> *SL languages?

No, a plain #lang with the syntactic code coverage enabled.


> They run their program, they see black/orange, they add tests, they no
> longer see black/orange, and they are confused?

Yes exactly -- and that's after I mention it in class and describe it in
the course pages.


> Did they not understand what black/orange means or were they expecting
> entirely black?

I think that by the time they work hard to cover everything and the
coverage colors disappear they quickly jump to a conclusion that
something is wrong.  -- I even have the server report to them about
uncovered code, but even that doesn't help.

In case it wasn't clear -- this is not too important, just something
that strikes me as weird every time another student gets confused.

-- 
((x=>x(x))(x=>x(x)))   Eli Barzilay:
http://barzilay.org/   Maze is Life!

-- 
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: (eqv? Racket-land Wonderland) -> #t

2016-02-14 Thread Jos Koot
I am a Racket-using hobbyist. It surprises me that, according to the
observation, not many hobbyists are using Racket.

I did programming in a lot of languages, assemblers included, often creating
my own languages, even long before I met Scheme or Racket or other Lisp like
languages in which it is much easier to implement a new language.

Shortly after retiring, almost two decades ago, I decided to stick to Racket
(at that time PLT-Scheme). I use it to study my own ideas of making other
languages and to check that I am well understanding mathematical algorithms.

My work is not a big addition to Racket, but some of my tiny advices did
make it.

My next project is to transform program fragments considered bad in
 
https://docs.racket-lang.org/guide/performance.html?q=performance
into code that would be accepted as good ones. Might be expensive at
expansion-time, but may improve run-time. Before starting this project I am
modifying my own Racket modules according to the advices in the above
reference. I must admit that much of my code makes offences against the
advices. Nevertheless it may help me to identify weak spots in poor code.

My 2 cents, Jos Koot



-Original Message-
From: racket-users@googlegroups.com [ 
mailto:racket-users@googlegroups.com] On Behalf Of Neil Van Dyke
Sent: domingo, 14 de febrero de 2016 15:26
To: Saša Janiška; racket-users@googlegroups.com
Subject: Re: [racket-users] Re: (eqv? Racket-land Wonderland) -> #t



Saša Janiška wrote on 02/14/2016 07:10 AM:
> Neil Van Dyke  writes:
>
>> Being non-mainstream for practitioners, Racket is most popular with
>> people who have the freedom to choose any tools they want, not forced
>> into a mainstream set of options. Most often this means individual
>> alpha techies, researchers, etc.
> That's true, but still wonder why not more hobbyist are using it.

I don't know how many Racket-using hobbyists there are.  I have found,
via Google, references to various Racket programming not in the package
systems, such as in blogs, by people I don't recall from the email
lists.  So I wonder whether the people who go to the trouble to release
open source packages and/or who participate on the email lists, are
actually the minority of users (not counting students required to use
Racket for classes).

I did have a book in the works, on practical software engineering in
Racket, which had baked into the process and tools very-low-friction
selective open source sharing of pieces of a system.  Based on the ideas
of how I thought that would work and why, I have a suspicion that we're
losing a lot of what could be open source packages (and additional
visible users).

Neil V.

--
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] (eqv? Racket-land Wonderland) -> #t

2016-02-14 Thread Richard Cleis
> So, at the end I just wonder how is it that such Wonderland is not
> discovered by much more people?

(My perspective is from working in the same place for 32 years)

- To claim progress, most people want to make only minimum changes to their way 
of doing things.

- To claim progress, most people do not want to make any change at all to their 
way of *thinking* about things.

- To claim a sound plan, managers only want to allow their people to attempt 
half of the above two points, and the second one is zero already.

I enjoy the freedom of using Racket because I gambled with its use and was 
immediately successful... and because it works fine on OSX, Linux, and Windows. 
However, the organization will never overtly endorse it due to the above points.

> 
> Thanks to all who help creating these wonders. ;)

Thanks to all who helped changed my way of thinking about solving problems 
(some of which have nothing to do with programming.)

rac


On Feb 13, 2016, at 10:31 AM, Saša Janiška wrote:

> Hello,
> 
> almost year ago I've become interested in Racket, but due to several
> reasons it did fall by the wayside. :-(
> 
> Recently I decided to migrate most of my tool-chain to Emacs (editor,
> org-mode, Gnus...) and then, naturally, when considering about learning
> some Elisp, I've remembered my past encounter with Racket which in the
> past did happen since I was looking for adequate language for
> multi-platform GUI app and Racket is one of the few modern and
> higher-level languages to provide 1st class support for it.
> 
> There is, of course, Scribble[1] to write high-quality
> documentation (I'll also try to provide Scribble support for writing web
> content in Nikola -- python-powered static-site-generator).
> 
> Lastly, when preparing slide-presentation for my wife (medicine), I did
> use LyX/LaTeX/Beamer, but considered to switch to ConTeXt in order to
> avoid having same-Beamer-look when I have found out about Slideshow
> library which means that by moving to and learning Racket I'll be able
> to write GUI app, write docs, web content and prepare nice presentations
> - everything just within the scope of single language!
> 
> Here I do not want to mention that Racket has wonderful ecosystem -
> package manager (btw, I'd like to see some support for using Fossil DVCS
> repos), building stand-alone executables etc.
> 
> So, at the end I just wonder how is it that such Wonderland is not
> discovered by much more people?
> 
> Thanks to all who help creating these wonders. ;)
> 
> 
> Sincerely,
> Gour
> 
> Footnotes: 
> [1]  I still consider to make use of Pollen!
> 
> -- 
> A self-realized man has no purpose to fulfill in the discharge
> of his prescribed duties, nor has he any reason not to perform
> such work. Nor has he any need to depend on any other living being.
> 
> -- 
> 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 toracket-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] Re: (eqv? Racket-land Wonderland) -> #t

2016-02-14 Thread Saša Janiška
Neil Van Dyke  writes:

> Being non-mainstream for practitioners, Racket is most popular with
> people who have the freedom to choose any tools they want, not forced
> into a mainstream set of options. Most often this means individual
> alpha techies, researchers, etc.

That's true, but still wonder why not more hobbyist are using it.

> I'd say the biggest downside is that there is still lots of things
> that are off-the-shelf for some mainstream platforms, but require some
> in-house DIY work for Racket. Sometimes this is something you can DIY
> faster and better than you can get an off-the-shelf solution
> integrated, but sometimes the DIY is just extra cost with no direct
> benefit.

Well, from the language itself down to the docs, everything looks
great...

> Disclosure: I'm a high-end consultant who prefers to use Racket for
> the majority of programming-level aspects, and can help an
> organization with architecture, process, training, etc. So I will tend
> to make money as commercial Racket adopters are successful.

Good to know. ;)

Btw, thank you for providing scribble-mode[1] - I'm sure I'll use it quite
often very soon!


Sincerely,
Gour

Footnotes: 
[1]  In order to reduce risk of RSI, I do use now Spacemacs and wonder
if there is plan to put scribble-mode @MELPA?

-- 
One who is not disturbed in mind even amidst the threefold
miseries or elated when there is happiness, and who is free
from attachment, fear and anger, is called a sage of steady mind.

-- 
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] using ryanc's oauth2 package with Google?

2016-02-14 Thread Fred Martin
Hi all,

I am trying to get oauth working with Google so I can write some Google Drive 
code in Racket.

I set up an "installed application" in a project in my Google dev console, and 
copied its ID to my Racket code.

When I try to get a token, it seems like everything is working -- I log into my 
Google account, select my app and grant it permission, and the browser redirect 
thinks that it succeeded in sending the auth code back to Racket.

But then I get the error oauth2:acquire-token/auth-code/json: failed: "HTTP/1.1 
400 Bad Request". 

Has anyone used this package lately? Below is the whole code for what I'm doing.

Thanks!

Fred



#lang racket

(require (planet ryanc/webapi:1:=1/oauth2))

(define myclient
  (oauth2-client
   #:id 
"548798434144-mhbmkbnlbi834tag326e5eojhgho9uco.apps.googleusercontent.com"
   #:secret #f))

; goes through the whole browser login and grant privs, and even seems
; to send the auth code back to localhost, 
; then fails with: 'oauth2:acquire-token/auth-code/json: failed: "HTTP/1.1 400 
Bad Request"'
(oauth2/request-auth-code/browser
 google-auth-server
 myclient
 '("https://www.googleapis.com/auth/drive;))

-- 
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: (eqv? Racket-land Wonderland) -> #t

2016-02-14 Thread Neil Van Dyke



Saša Janiška wrote on 02/14/2016 07:10 AM:

Neil Van Dyke  writes:


Being non-mainstream for practitioners, Racket is most popular with
people who have the freedom to choose any tools they want, not forced
into a mainstream set of options. Most often this means individual
alpha techies, researchers, etc.

That's true, but still wonder why not more hobbyist are using it.


I don't know how many Racket-using hobbyists there are.  I have found, 
via Google, references to various Racket programming not in the package 
systems, such as in blogs, by people I don't recall from the email 
lists.  So I wonder whether the people who go to the trouble to release 
open source packages and/or who participate on the email lists, are 
actually the minority of users (not counting students required to use 
Racket for classes).


I did have a book in the works, on practical software engineering in 
Racket, which had baked into the process and tools very-low-friction 
selective open source sharing of pieces of a system.  Based on the ideas 
of how I thought that would work and why, I have a suspicion that we're 
losing a lot of what could be open source packages (and additional 
visible users).


Neil V.

--
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] Re: using ryanc's oauth2 package with Google?

2016-02-14 Thread Fred Martin
So... even though I chose "Other" as the client type, my API credentials were 
created with a secret.

I had to copy the secret into my client constructor request.

>From my reading of the oauth 2 API docs, I thought "installed app" clients 
>weren't supposed to have secrets?

Anyway at this point, I have a validated oauth2 object, with its access token :)

Fred

-- 
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] DrRacket Coverage

2016-02-14 Thread Eli Barzilay
Every semester there are always students that think that DrRacket is
broken when they add tests and the coverage colors go away.  I now tell
them about it in advance (in class and in text), but it's still
confusing people.

So in the spirit of phone apps which teach you about themselves, how
about something like a dialog popping up when coverage is enabled, and
there is a non-trivial program, and there's complete coverage.
Something like a short explanation of how the colors are the same since
your code is completely covered, with a "got it" button to dismiss it.

-- 
((x=>x(x))(x=>x(x)))   Eli Barzilay:
http://barzilay.org/   Maze is Life!

-- 
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] Chaperone of immutable hash

2016-02-14 Thread Gustavo Massaccesi
Thanks to both. I searched by mistake "make-chaperone-hash" instead of
"chaperone-hash", so I didn't find it.

Gustavo

On Sat, Feb 13, 2016 at 7:11 PM, Stephen Chang  wrote:
> I added similar basic tests here.
>
> https://github.com/racket/racket/blob/master/pkgs/racket-test-core/tests/racket/hash.rktl
>
> On Feb 13, 2016 4:12 PM, "Robby Findler" 
> wrote:
>>
>> I think this is what you want?
>>
>> (chaperone-hash
>>  (hash)
>>  (λ (h key) (values key (λ (h key val) val)))
>>  (λ (h key val) (values key val))
>>  (λ (h key) key)
>>  (λ (h key) key)
>>  (λ (hash) 'okay)
>>  (λ (hash key) key))
>>
>>
>>
>>
>> On Sat, Feb 13, 2016 at 3:02 PM, Gustavo Massaccesi 
>> wrote:
>> > I want to make a test with a chaperone of an immutable hash, but the
>> > signature of make-chaperone-hash has too many parts.
>> >
>> > Do anyone have an example of use of make-chaperone-hash. If possible,
>> > the chaperone that does nothing, only forward the values.
>> >
>> > Gustavo
>> >
>> > --
>> > 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.

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