Re: [racket-users] racket on android (Was: Racket modules in R6RS?)

2015-06-11 Thread Neil Van Dyke

Matthew Flatt wrote on 06/11/2015 10:00 PM:

Android via NDK is a supported platform.


Matthew, that's great.  Thank you.

Anyone implemented `racket/gui` for Android with this, or otherwise 
hooked up things so that the Racket program can drive a UI on Android?


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.


Re: [racket-users] right abstraction for this?

2015-06-11 Thread Vincent St-Amour
As Greg points out, it was directly inspired by SQL's `group-by`. I've
found it really handy when thinking about data in a relational way.

Anyone opposed to moving it to `racket/list`? That would make it more
discoverable?

Vincent



At Thu, 11 Jun 2015 11:17:26 -0700,
'John Clements' via users-redirect wrote:
> 
> 
> > On Jun 11, 2015, at 10:19 AM, Stephen Chang  wrote:
> > 
> > Would any of the functions in unstable/list help? For example,
> 
> Ah, ‘group-by’ is very nice, yes. Looks like that was Vincent’s? Many thanks, 
> Vincent!
> 
> John
> 
> 
> -- 
> 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] racket on android (Was: Racket modules in R6RS?)

2015-06-11 Thread Matthew Flatt
Android via NDK is a supported platform. The "src/README" file has information 
on cross-compilation and specific hints for Android. I'm not in a position to 
double check just now, but it built the last time I tried a few months ago.

Embedding should be as easy as on any platform. I wouldn't classify it as 
"easy" in absolute terms, but it shouldn't be too difficult for a typical host 
application - maybe on par with making a portable Scheme program.

> On Jun 12, 2015, at 9:33 AM, Neil Van Dyke  wrote:
> 
> Has anyone tried to build Racket 6.x for the Android NDK (or whatever is the 
> current way to do native code)?  That might be the fastest path, rather than 
> targeting Dalvik, Java, or JS.
> 
> Encouraging: I did find that Racket 6.x builds pretty easily as a 
> possibly-viably-sized OpenWrt package, which gives me some hope that Android 
> NDK might be low-hanging fruit as well.  (Though Android apps are more 
> complicated than OpenWrt binaries are.  Good news is that Android devices do 
> tend to have lots more RAM and CPU than OpenWrt ones.)
> 
> -rw-r--r--  1 user user 5531012 May 11 17:57 racket_6.1.1-1_ar71xx.ipk
> -rw-r--r--  1 user user 5804296 May 17 06:35 racket_6.1.91.900-1_ar71xx.ipk
> 
> 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.


[racket-users] racket on android (Was: Racket modules in R6RS?)

2015-06-11 Thread Neil Van Dyke
Has anyone tried to build Racket 6.x for the Android NDK (or whatever is 
the current way to do native code)?  That might be the fastest path, 
rather than targeting Dalvik, Java, or JS.


Encouraging: I did find that Racket 6.x builds pretty easily as a 
possibly-viably-sized OpenWrt package, which gives me some hope that 
Android NDK might be low-hanging fruit as well.  (Though Android apps 
are more complicated than OpenWrt binaries are.  Good news is that 
Android devices do tend to have lots more RAM and CPU than OpenWrt ones.)


-rw-r--r--  1 user user 5531012 May 11 17:57 racket_6.1.1-1_ar71xx.ipk
-rw-r--r--  1 user user 5804296 May 17 06:35 racket_6.1.91.900-1_ar71xx.ipk

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.


Re: [racket-users] Racket modules in R6RS?

2015-06-11 Thread Matthias Felleisen

Short: What I am trying to say is that after R6RS, we moved on from Scheme. 
Don't expect us to support it, don't expect us to stand it its way. We are 
moving in an orthogonal direction. 

Long:  We appreciate "small kernel" language and we inherited this from Scheme. 
We do not appreciate it "keep the language small, even at the cost of not being 
able to support the construction of large projects easily."  Certain degrees of 
safety and security, certain partial abstraction layers, certain fundamental 
language mechanisms are essential to us. That, and the idea that batteries are 
included in a useful manner. 

We wish our implementation were smaller. One day we will have a small one. 

No, I can't tell you it's easy to embed Racket in an Android app but I am 
certain that if you call for help on this list, someone will help. Or perhaps 
several people. But it won't be tat small. Tony GJ, for example, had real 
trouble running Racket on a Linksys router a couple of years back and these 
things run Linux. Then again, phones are larger than routers ;-) 


-- Matthias



On Jun 11, 2015, at 7:48 PM, John Carmack wrote:

> I appreciate the position, but I do think there is still value in being able 
> to optionally carve off all the extra goodness and act like a more primitive 
> Scheme to provide compatibility with various embedded options where full 
> Racket isn’t practical.
>  
> DrRacket is a key element of my strategy here – a cross platform IDE with 
> brace matching, syntax highlighting, and a debugger makes Scheme a reasonable 
> choice for an extension language.  I think I can evangelize this in a way 
> that wouldn’t be possible if users’ first experience was poking at code in 
> Notepad.
>  
> If anyone wants to tell me “Racket is easy to embed in an Android app!” I 
> would love to hear it, but I’m a little too intimidated to have a crack at it 
> myself, versus Chibi or various other small Schemes that are just a few files 
> of C code.
>  
>  
> From: Matthias Felleisen [mailto:matth...@ccs.neu.edu] 
> Sent: Thursday, June 11, 2015 7:05 PM
> To: John Carmack
> Cc: Racket Users
> Subject: Re: [racket-users] Racket modules in R6RS?
>  
>  
> Let me rephrase Matthew. Racket is only related to Scheme. See 
> http://racket-lang.org/new-name.html for an explanation of our move. Our 
> understanding is that the Scheme community wants to move back to a world 
> where the language is small while Racket wants to move to a world where 
> programmers can easily create programs. -- Matthias
>  
>  
>  
>  
>  
> On Jun 11, 2015, at 3:22 PM, John Carmack wrote:
> 
> 
> How do you include a racket module in an R6RS program?
>  
> I have remote.rkt in the same directory as test.scm.
>  
> With R5RS I could do (#%require "remote.rkt"), but that doesn’t work, and I 
> tried various things in the (import) statement without success.
>  
> Are there any plans for an R7RS lang in Racket?  I am trying to write code 
> that runs in both DrRacket and Chibi scheme.
>  
>  
>  
> -- 
> 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] Racket modules in R6RS?

2015-06-11 Thread John Carmack
I appreciate the position, but I do think there is still value in being able to 
optionally carve off all the extra goodness and act like a more primitive 
Scheme to provide compatibility with various embedded options where full Racket 
isn't practical.

DrRacket is a key element of my strategy here - a cross platform IDE with brace 
matching, syntax highlighting, and a debugger makes Scheme a reasonable choice 
for an extension language.  I think I can evangelize this in a way that 
wouldn't be possible if users' first experience was poking at code in Notepad.

If anyone wants to tell me "Racket is easy to embed in an Android app!" I would 
love to hear it, but I'm a little too intimidated to have a crack at it myself, 
versus Chibi or various other small Schemes that are just a few files of C code.


From: Matthias Felleisen [mailto:matth...@ccs.neu.edu]
Sent: Thursday, June 11, 2015 7:05 PM
To: John Carmack
Cc: Racket Users
Subject: Re: [racket-users] Racket modules in R6RS?


Let me rephrase Matthew. Racket is only related to Scheme. See 
http://racket-lang.org/new-name.html for an explanation of our move. Our 
understanding is that the Scheme community wants to move back to a world where 
the language is small while Racket wants to move to a world where programmers 
can easily create programs. -- Matthias





On Jun 11, 2015, at 3:22 PM, John Carmack wrote:


How do you include a racket module in an R6RS program?

I have remote.rkt in the same directory as test.scm.

With R5RS I could do (#%require "remote.rkt"), but that doesn't work, and I 
tried various things in the (import) statement without success.

Are there any plans for an R7RS lang in Racket?  I am trying to write code that 
runs in both DrRacket and Chibi scheme.



--
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] Racket modules in R6RS?

2015-06-11 Thread Matthias Felleisen

Let me rephrase Matthew. Racket is only related to Scheme. See 
http://racket-lang.org/new-name.html for an explanation of our move. Our 
understanding is that the Scheme community wants to move back to a world where 
the language is small while Racket wants to move to a world where programmers 
can easily create programs. -- Matthias





On Jun 11, 2015, at 3:22 PM, John Carmack wrote:

> How do you include a racket module in an R6RS program?
>  
> I have remote.rkt in the same directory as test.scm.
>  
> With R5RS I could do (#%require "remote.rkt"), but that doesn’t work, and I 
> tried various things in the (import) statement without success.
>  
> Are there any plans for an R7RS lang in Racket?  I am trying to write code 
> that runs in both DrRacket and Chibi scheme.
>  
>  
> 
> -- 
> 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] Re: Racket modules in R6RS?

2015-06-11 Thread Philip Blair
On Thursday, June 11, 2015 at 4:22:19 PM UTC-4, John Carmack wrote:
> How do you include a racket module in an R6RS program?
> 
>  
> 
> I have remote.rkt in the same directory as test.scm.
> 
>  
> 
> With R5RS I could do (#%require "remote.rkt"), but that doesn’t work, and I 
> tried various things in the (import) statement without success.
> 
>  
> 
> Are there any plans for an R7RS lang in Racket?  I am trying to write code 
> that runs in both DrRacket and Chibi scheme.
> 
>  
> 
>  

I managed to get something working:

The Racket r5rs documentation states that the `#%require` form is provided from 
racket/base. Since typing `#%require` raises (as far as I've experienced) an 
"illegal character after '#' input: '%'" error, I had to fall back onto the 
standard `require` form:

remote.rkt:

#lang racket
(provide foo)

(define (foo x) (add1 x))


test.scm:

#!r6rs
(import (rnrs)
(only (racket base) require))
(require "remote.rkt")
(display (foo 2))


It's not an "r6rs-pure" solution, unfortunately, but, as mflatt said, there's 
no real way do this in pure r6rs. I don't know your use case, but this might 
work for you.

-- 
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] System Scheme (RnRS): Shared Secret Generator

2015-06-11 Thread Matthew Flatt
At Wed, 10 Jun 2015 18:44:15 +0200, Michael Titke wrote:
> On 10/06/2015 12:33, Michael Titke wrote:
> > I changed from one OS to another and I was missing a simple feature: 
> > automatic password generation. To fill the gap with a Scheme I 
> > implemented such a generator as a command line tool respectively 
> > /crypto sweet/.
> >
> > After having read /SRFI 27: Sources of Random Bits/ I decided to 
> > implement my algorithm natively with /Guile 1.8/ and /Racket 6.1/. 
> > There is some portability of simple RnRS System Scheme programs: right 
> > now it seems that the "heritage" of the Scheme Shell (/scsh/) grants 
> > portability across UNIX/POSIX/SUS systems.
> >
> > Even when it comes to true randomness as perhaps generated by the 
> > noise in the low order magnitudes/bits of hardware sensors which is 
> > enhanced and accessible with the file system device entry 
> > "/dev/urandom" this simple System Scheme Script remains portable. 
> > Accessing entropy pools on other systems should be as easy - perhaps 
> > with the foreign function interface.
> >
> > With real entropy pools the need for the interface described by SRFI 
> > 27 vanishes almost completely. It's still a good idea to seed some 
> > randomizing function with real entropy before using it but randomizing 
> > functions do IMHO not constitute a domain of their own whereas SRFI 27 
> > declares them to be.
> >
> >
> >
> > -- 
> > 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.
> The expressions used in this text might diverge significantly from usual 
> mathematical terminology.
> But I didn't study maths at university ...
> 
> There seems to be a strong bias in the /Racket/ version (three examples: 
> "G3GpGGGCuG3u", "GGIGYGGGI9GG", "mGCnF3G,") with a lot of capital 
> letter Gs so please don't use it in production environments.
>   This bias is that obvious because there neither is a further 
> permutation of the initial character sets nor an obfuscation of the 
> result. But this bias might mean that the procedure /random/ is not 
> (what I call) /holomorphic/: the procedure /random /does not "spread or 
> distribute the seed" across the destination space (one dimension with a 
> magnitude denoted by n). Filling all the 31 bits of the seed might 
> produce visually more appealing results but it could as well be as 
> strongly biased as the examples given. In my understanding of /random/ 
> as an /unstable function/ *the current behavior is **wrong* or I missed 
> some point about Racket's randomness. Right now it seems to have the 
> opposite effect of an unstable function: it seems to reduce the entropy 
> in the given example like a stabilizer where it should act as a 
> randomizer ...
> 
> The other version does not have such an obvious bias but I have not yet 
> analyzed the "saturation / distribution" and other properties of the 
> resulting shared secrets. Right now I do not have the time to check this 
> and I don't want to file a bug report as long as I'm not sure about the 
> source of the bias.

I'm not sure I follow, but I think you're right to suggest an issue
with `random-seed`. The space of inputs for `random-seed` is much
smaller than the state of the random-number generator, and by
repeatedly setting the seed that way, you're reducing the space of
generated numbers; it makes sense that it would also bias the generated
numbers in various.

Does using `vector->pseudo-random-generator!` in place of `random-seed`
solve the problem?

-- 
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] Racket modules in R6RS?

2015-06-11 Thread Matthew Flatt
At Thu, 11 Jun 2015 20:22:16 +, John Carmack wrote:
> How do you include a racket module in an R6RS program?
> 
> I have remote.rkt in the same directory as test.scm.
> 
> With R5RS I could do (#%require "remote.rkt"), but that doesn't work, and I 
> tried various things in the (import) statement without success.

The `import` form in the R6RS implementation doesn't currently support
relative references to modules. It can only reference modules through
collection paths, so a module has to be "installed" to be accessible.

For example, if "remote.rkt" is placed in "my-utils" directory that
is linked as a package with (the trailing slash is important)

 raco pkg install my-utils/

then

 (import (my-utils remote))

accesses the module.


> Are there any plans for an R7RS lang in Racket?

I'm not aware of any plans.

Note that the R6RS implementation isn't built-in to Racket; it's just a
pile of libraries. I expect that R7RS could be implemented similarly in
its own package, but I am not aware of anyone working on that package,
so far.

-- 
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] Not too late for Strange Loop (maybe)

2015-06-11 Thread Brian Mastenbrook
On Jun 11, 2015, at 14:29, 'John Clements' via users-redirect 
 wrote:

> Golly, that was fast.

According to the registration site, more tickets may be available on the 25th: 
"Strange Loop regular tickets are currently sold out. We are sorting through 
other ticket pools (sponsors, speakers, etc) and if possible, will make some 
more tickets available on June 25th at noon Central. In any case, a wait list 
will be enabled then that can be filled based on cancellations, etc."

http://regonline.com/strangeloop2015

--
Brian Mastenbrook
br...@mastenbrook.net
http://brian.mastenbrook.net/

-- 
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] Racket modules in R6RS?

2015-06-11 Thread John Carmack
How do you include a racket module in an R6RS program?

I have remote.rkt in the same directory as test.scm.

With R5RS I could do (#%require "remote.rkt"), but that doesn't work, and I 
tried various things in the (import) statement without success.

Are there any plans for an R7RS lang in Racket?  I am trying to write code that 
runs in both DrRacket and Chibi scheme.


-- 
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] ...aaand, too late to register for Strange Loop.

2015-06-11 Thread 'John Clements' via users-redirect

> On Jun 11, 2015, at 12:32 PM, Robby Findler  
> wrote:
> 
> I understand it may be too far to come for just one day for many, but
> RacketCon registration is independent of Strange Loop registration.

Indeed… I apologize for suggesting otherwise!

John

-- 
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] ...aaand, too late to register for Strange Loop.

2015-06-11 Thread Robby Findler
I understand it may be too far to come for just one day for many, but
RacketCon registration is independent of Strange Loop registration.

Robby


On Thu, Jun 11, 2015 at 2:29 PM, 'John Clements' via users-redirect
 wrote:
> Golly, that was fast. So much for RacketCon this year.
>
> My fault, I know.
>
> John
>
>
>
> --
> 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] ...aaand, too late to register for Strange Loop.

2015-06-11 Thread 'John Clements' via users-redirect
Golly, that was fast. So much for RacketCon this year.

My fault, I know.

John



-- 
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] right abstraction for this?

2015-06-11 Thread 'John Clements' via users-redirect

> On Jun 11, 2015, at 10:19 AM, Stephen Chang  wrote:
> 
> Would any of the functions in unstable/list help? For example,

Ah, ‘group-by’ is very nice, yes. Looks like that was Vincent’s? Many thanks, 
Vincent!

John


-- 
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] right abstraction for this?

2015-06-11 Thread Greg Hendershott
IIUC in SQL this would simply be:

SELECT student, AVG(rating)
FROM scores
GROUP BY student

Apparently a DSL for querying tables can be handy. :)


The Racket equivalent for the special case of a 2-column table (a
hash-table) could be something like:

(define (sql-ish-aggregate-group-by f xs)
  (for/hash ([(k v) (in-hash (for/fold ([ht (hash)]) ; a "gather"
   ([x (in-list xs)])
   (match-define (list k v) x)
   (hash-update ht k (λ (vs) (cons v vs)) '(])
(cons k (f v


"Group by" seems to be a Rorschach phrase; overloaded meanings.
Clojure has a group-by that differs from SQL or unstable/list.  I
don't know Clojure well enough to code golf this.

-- 
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] right abstraction for this?

2015-06-11 Thread Stephen Chang
Would any of the functions in unstable/list help? For example,

#lang racket
(require unstable/list)

(define (gather lst)
  (for/hash ([g (group-by car lst)])
(values (caar g) (append-map cdr g

(gather '((a c) (a d) (b e) (b f)))
; => '#hash((a . (c d)) (b . (e f)))

On Thu, Jun 11, 2015 at 12:25 PM, 'John Clements' via users-redirect
 wrote:
> I write this kind of code all the darn time:
>
> ;; take (listof (list a b)) into (hashof a (listof b))
> (define (gather l)
>   (for/fold ([ht (make-hash)])
> ([pr l])
> (hash-set ht (first pr) (cons (second pr)
>   (hash-ref ht (first pr) empty)
>
> ;; gather the responses into a table:
> (define rating-table (gather responses2))
>
> ;; compute the mean rating for each student
> (for/list ([(student ratings) (in-hash rating-table)])
>   (list student (mean ratings)))
>
> … that is: given an association list, gather them together, then compute 
> (say) the mean of the values. In this case, I’m trying to compute the mean 
> rating for a bunch of students. Very simple.
>
> So… why does it take so much code? I feel like these should be built-in 
> abstractions. There are (at least) two possibilities:
>
> 1) There’s an obvious, built-in way to do this, and I’m just missing it.
> 2) There’s an abstraction that we’re missing, and I feel like Clojure might 
> have it. Or am I just making this up? Getting clojure running is such a pain….
>
> Thanks for any advice!
>
> John
>
> --
> 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] right abstraction for this?

2015-06-11 Thread 'John Clements' via users-redirect
I write this kind of code all the darn time:

;; take (listof (list a b)) into (hashof a (listof b))
(define (gather l)
  (for/fold ([ht (make-hash)])
([pr l])
(hash-set ht (first pr) (cons (second pr)
  (hash-ref ht (first pr) empty)

;; gather the responses into a table:
(define rating-table (gather responses2))

;; compute the mean rating for each student
(for/list ([(student ratings) (in-hash rating-table)])
  (list student (mean ratings)))

… that is: given an association list, gather them together, then compute (say) 
the mean of the values. In this case, I’m trying to compute the mean rating for 
a bunch of students. Very simple.

So… why does it take so much code? I feel like these should be built-in 
abstractions. There are (at least) two possibilities:

1) There’s an obvious, built-in way to do this, and I’m just missing it.
2) There’s an abstraction that we’re missing, and I feel like Clojure might 
have it. Or am I just making this up? Getting clojure running is such a pain….

Thanks for any advice!

John

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