Re: [racket-users] Iterating through a list more than one at a time

2016-08-04 Thread David Storrs
Great, thank you.  I was thinking maybe there was some construct that could
do this built-in, the way 'map' can double as 'zip'.

I looked through sugar and it looks very convenient; I'll be using it in
future.  Note that when I installed it, I got the following:

[...snip lots of "raco setup: 0 skipping: /..." lines]
raco setup: docs failure: query-exec: unable to open the database file
  error code: 14
  SQL: "ATTACH $1 AS other"
  database: #
  mode: 'read-only
  file permissions: (write read)
raco setup: --- installing collections ---
raco setup: --- post-installing collections ---
raco pkg install: packages installed, although setup reported errors

Doesn't seem to have mattered and it might just be something weird about
permissions on my system.  I figured I'd mention it, though.

Dave


On Thu, Aug 4, 2016 at 5:04 PM, Matthew Butterick  wrote:

>
> On Aug 4, 2016, at 3:10 PM, David Storrs  wrote:
> > I'd like to be able to iterate over a list N elements at a time -- e.g.,
> grab elements 1 and 2, do something with them, grab 3 and 4, etc.
>
> Your technique seems fine. You could use `split-at` if you wanted to save
> a list operation, otherwise it's the standard recursion pattern:
>
> #lang racket
> (define data '(("foo") ("bar")  ("baz")  ("jaz") ("quux") ("glug")))
>
> (define (step-by-n func xs [num 2])
>   (if (null? xs)
>   null
>   (let-values ([(head tail) (split-at xs num)])
> (cons (func head) (step-by-n func tail num)
>
> (step-by-n (λ (xx) (apply hash (map car xx))) data)
>
> (step-by-n (λ (xxx) (hash (caar xxx) (map car (cdr xxx data 3)
>
>
> I wrote a utility function called `slice-at` to handle this problem. [1]
>
>
> [1] http://docs.racket-lang.org/sugar/#%28def._%28%28lib._
> sugar%2Flist..rkt%29._slice-at%29%29

-- 
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] Iterating through a list more than one at a time

2016-08-04 Thread Matthew Butterick

On Aug 4, 2016, at 3:10 PM, David Storrs  wrote:
> I'd like to be able to iterate over a list N elements at a time -- e.g., grab 
> elements 1 and 2, do something with them, grab 3 and 4, etc.

Your technique seems fine. You could use `split-at` if you wanted to save a 
list operation, otherwise it's the standard recursion pattern:

#lang racket
(define data '(("foo") ("bar")  ("baz")  ("jaz") ("quux") ("glug")))

(define (step-by-n func xs [num 2])
  (if (null? xs)
  null
  (let-values ([(head tail) (split-at xs num)])
(cons (func head) (step-by-n func tail num)

(step-by-n (λ (xx) (apply hash (map car xx))) data)

(step-by-n (λ (xxx) (hash (caar xxx) (map car (cdr xxx data 3)


I wrote a utility function called `slice-at` to handle this problem. [1]


[1] 
http://docs.racket-lang.org/sugar/#%28def._%28%28lib._sugar%2Flist..rkt%29._slice-at%29%29

-- 
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] Iterating through a list more than one at a time

2016-08-04 Thread David Storrs
I feel like there should be a simpler way to do this, but I haven't found
one despite much Googling and reading of docs about "for" and its
siblings.  Can someone point me the right way?


I'd like to be able to iterate over a list N elements at a time -- e.g.,
grab elements 1 and 2, do something with them, grab 3 and 4, etc.

This will do the job, but I suspect there's a more built-in way:

(define data '(("foo") ("bar")  ("baz")  ("jaz") ("quux") ("glug")))

(define (step-by-n func data [num 2])
  (if (null? data)
  (func '())
  (append (func (take data num))
  (step-by-n func (drop data num) num

(step-by-n (lambda (l)
 (if (null? l)
 '()
 (list (hash (car (first l))
 (car (second l))
   data)

(step-by-n (lambda (l)
 (if (null? l)
 '()
 (list (hash (car (first l))
 (list (car (second l))
   (car (third l)))
   data
   3)

OUTPUT:
'(#hash(("foo" . "bar")) #hash(("baz" . "jaz")) #hash(("quux" . "glug")))
'(#hash(("foo" . ("bar" "baz"))) #hash(("jaz" . ("quux" "glug"


(Note that the fact that it returns the results as a list was a deliberate
choice but not an essential one.)

-- 
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] Run Button interaction

2016-08-04 Thread Stephen De Gabrielle
My apologies - it is in the tools docs:

http://docs.racket-lang.org/tools/drracket_unit.html#%28meth._%28%28%28lib._drracket%2Ftool-lib..rkt%29._drracket~3aunit~3aframe~25%29._execute-callback%29%29
On Thu, 4 Aug 2016 at 15:43, Robby Findler 
wrote:

> Did you try
>
>   (define/override ...
>
> ?
>
> Robby
>
>
> On Thu, Aug 4, 2016 at 9:41 AM, Normal Loone 
> wrote:
> > I tried
> >
> > (define/augment (execute-callback)
> > ...)
> >
> > So I'd just use another additional function of mine when the run button
> is used, but execute-callback is apparently not augmentable? At least I got
> an error message stating that.
> >
> > Is there another function that you can modify?
> >
> > --
> > 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.
>
-- 
Kind regards,
Stephen
--
Bigger than Scheme, cooler than Clojure & more fun than CL.(n=1)
--

-- 
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] Playing with finite groups.

2016-08-04 Thread Jos Koot
To whom is interested

https://github.com/joskoot/restricted-permutations

A module that represents permutations by bijections, id est, by functions.
Documentation (scribble) is included.
Care has been taken such that two permutations representing
the same mathemathical permutation are the same in the sense of [eq?].
Finite groups of restricted permutations are the same in the sense of [eq?] too.
Much depends on exactness of numbers, which in many languages does not exist.
Therefore Racket seems a nice vehicle to me.
Criticism is welcome, of course.

Jos

PS: I am working on an exact representation of the values of nj-symbols and 
Clebsch-Gordon coefficients,
but this is about infinite groups of symmetries in O3.
Before going to O8, I have to study more. 

-- 
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] equivalence relation for hash keys

2016-08-04 Thread Jos Koot
Thanks,
A usefull advice.
I already did something like that, using a guard-like construction that 
normalizes the key.
I use it for procedures (structs with procedure-property) that have to be eq? 
when representing the same mathematical function.
This way I can spare much memory and many cpu cycles.
However, I don't want all my objects being wrapped in structs.
Not all my data are lists. Some of them are seteq-s that are used as sequences.
I suppose using gen:equal+hash can do the same for me.
Nonentheless, by now I have all the info I need (and that, by now, I am 
familiar with)
Thanks again,
Jos

  _  

From: Jon Zeppieri [mailto:zeppi...@gmail.com] 
Sent: jueves, 04 de agosto de 2016 19:06
To: Jos Koot
Cc: Racket Users
Subject: Re: [racket-users] equivalence relation for hash keys




On Thu, Aug 4, 2016 at 12:34 PM, Jos Koot  wrote:




Hi 

As far as I can see a hash has three options only for the equivalence relation 
comparing keys: eq?, eqv? and equal?. 
Would it be possible to extend Racket such as to allow the preparation of 
hashes with a user specified equivalence relation?

 snip 

Thanks, Jos



Or you could wrap your data (lists, I take it) in structs and define methods 
for gen:equal+hash on your struct type.

-J
 

-- 
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] How do I "make base"

2016-08-04 Thread Vincent St-Amour
Tim,

Do keep in mind that, even if you check out a specific release tag
(e.g., to build something equivalent to 6.6), `raco pkg` will pull in
the latest version of packages in the main distributions when possible,
rather than the versions packaged with the 6.6 installers. If that's
what you want, you should have your install use the 6.6 release catalog.

Of course, if you're fine with running directly from `master`, none of
this applies.

Vincent



On Thu, 04 Aug 2016 06:15:15 -0500,
Tim Brown wrote:
> 
> William, Stephen,
> 
> Thank you for your help. It seems that what I want to do is not an
> appropriate use of the prepackaged source, and I am now progressing
> using a git clone.
> 
> Thanks again,
> 
> Tim
> 
> On 03/08/2016 18:11, William J. Bowman wrote:
> > I always forget the build process when I'm hacking on Racket too and have 
> > to glare at the INSTALL file
> > for a while.
> > Maybe the INSTALL file has too much detail, or the wrong details, and the 
> > instructions get lost in it?
> > 
> > I always build a minimal install via `make PKGS=base in-place` from the 
> > top-level directory of the Racket
> > repo, then install everything else via `raco pkg install`.
> > Binaries, including raco, end up in `racket/racket/bin`.
> > 
> > --
> > William J. Bowman
> > 
> > 
> > On Wed, Aug 03, 2016 at 06:02:53PM +0100, Tim Brown wrote:
> >> Here's hoping someone can answer this without too much (any) difficulty:
> >> 
> >> I have the Unix source in racket-6.6-src.tgz from the download page.
> >> It's untarred into racket-6.6 . I want this because it has a superset
> >> of the packages I'll eventually want in my installation.
> >> 
> >> If I:
> >> 
> >>   configure
> >>   make
> >>   make plain-install
> >> 
> >> I don't get a raco executable built.
> >> 
> >> On IRC, it was suggested that I do a `make base` -- which should get me
> >> a raco capabale of pkg and setup. Problem is -- I can't find base as a
> >> target.
> >> 
> >> It was also suggested that it is not in src/Makefile, instead:
> >> "I'm usually in the top-level checkout dir", to quote stamourv.
> >> 
> >> A git clone later and I *still* don't have base in any makefile.
> >> 
> >> Folks... how do I either make base or get as minimal a racket
> >> installation as I can with a capable raco?
> >> 
> >> Thanks in anticipation,
> >> 
> >> Tim
> >> 
> >> --
> >> Tim Brown - t...@timb.net - +44(0)7771714159
> >> 
> >> --
> >> 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.
> 
> 
> -- 
> Tim Brown - t...@timb.net - +44(0)7771714159
> 
> -- 
> 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] equivalence relation for hash keys

2016-08-04 Thread Jos Koot
 
Thanks again.
Just had a look. The docs are very clear.
Jos

-Original Message-
From: Ryan Culpepper [mailto:ry...@ccs.neu.edu] 
Sent: jueves, 04 de agosto de 2016 18:40
To: Jos Koot; 'Racket Users'
Subject: Re: [racket-users] equivalence relation for hash keys

See `define-custom-hash-types` in `racket/dict`. Note that you'll need 
to use `dict-ref` instead of `hash-ref`, etc.

Ryan


snip

-- 
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] equivalence relation for hash keys

2016-08-04 Thread Jon Zeppieri
On Thu, Aug 4, 2016 at 12:34 PM, Jos Koot  wrote:

> Hi
>
> As far as I can see a hash has three options only for the equivalence
> relation comparing keys: eq?, eqv? and equal?.
> Would it be possible to extend Racket such as to allow the preparation of
> hashes with a user specified equivalence relation?
>
> May be I can prepare it myself, but I have no idea where to start.
> Pointers welcome, of course.
>
> For example, I am interested in a hash with the following equivalence
> relation for its keys:
>
> (lambda (x y) (equal? (sort x <) (sort y <)))
> x : exact-nonnegative-integer?
> y : exact-nonnegative-integer?
>
> Thanks, Jos
>


Or you could wrap your data (lists, I take it) in structs and define
methods for gen:equal+hash on your struct type.

-J

-- 
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] equivalence relation for hash keys

2016-08-04 Thread Jos Koot
Thanks, I'll look into that.
Jos 

-Original Message-
From: Ryan Culpepper [mailto:ry...@ccs.neu.edu] 
Sent: jueves, 04 de agosto de 2016 18:40
To: Jos Koot; 'Racket Users'
Subject: Re: [racket-users] equivalence relation for hash keys

See `define-custom-hash-types` in `racket/dict`. Note that you'll need 
to use `dict-ref` instead of `hash-ref`, etc.

Ryan


On 08/04/2016 12:34 PM, Jos Koot wrote:
> Hi
>
> As far as I can see a hash has three options only for the equivalence
> relation comparing keys: eq?, eqv? and equal?.
> Would it be possible to extend Racket such as to allow the preparation
> of hashes with a user specified equivalence relation?
>
> May be I can prepare it myself, but I have no idea where to start.
> Pointers welcome, of course.
>
> For example, I am interested in a hash with the following equivalence
> relation for its keys:
>
> (lambda (x y) (equal? (sort x <) (sort y <)))
> x : exact-nonnegative-integer?
> y : exact-nonnegative-integer?
>
> Thanks, Jos
>
>
> --
> 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] equivalence relation for hash keys

2016-08-04 Thread Ryan Culpepper
See `define-custom-hash-types` in `racket/dict`. Note that you'll need 
to use `dict-ref` instead of `hash-ref`, etc.


Ryan


On 08/04/2016 12:34 PM, Jos Koot wrote:

Hi

As far as I can see a hash has three options only for the equivalence
relation comparing keys: eq?, eqv? and equal?.
Would it be possible to extend Racket such as to allow the preparation
of hashes with a user specified equivalence relation?

May be I can prepare it myself, but I have no idea where to start.
Pointers welcome, of course.

For example, I am interested in a hash with the following equivalence
relation for its keys:

(lambda (x y) (equal? (sort x <) (sort y <)))
x : exact-nonnegative-integer?
y : exact-nonnegative-integer?

Thanks, Jos


--
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] equivalence relation for hash keys

2016-08-04 Thread Jos Koot
Hi

As far as I can see a hash has three options only for the equivalence relation 
comparing keys: eq?, eqv? and equal?.
Would it be possible to extend Racket such as to allow the preparation of 
hashes with a user specified equivalence relation?
May be I can prepare it myself, but I have no idea where to start. Pointers 
welcome, of course.

For example, I am interested in a hash with the following equivalence relation 
for its keys:

(lambda (x y) (equal? (sort x <) (sort y <)))
x : exact-nonnegative-integer?
y : exact-nonnegative-integer?

Thanks, Jos


-- 
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] nj-symbols and clebsch-gordon coefficients

2016-08-04 Thread Jos Koot
Hi

IIRC all nj-symbols and Clebsch-Gordon coefficients are plus or minus the 
square root of a positive rational number.
IIAC this means that a nj-symbol or Clebsch-Gordon coefficient can be 
represented exactly by a sign and its square.
Question: is this correct? If so, is there already some code that does this.
If not, I am prepared to produce it (using a hash in order to speed up)
The recursion relations seem to confirm my IIRC of the first line.
Would this be usefull?

Jos Koot



-- 
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] Run Button interaction

2016-08-04 Thread Robby Findler
Did you try

  (define/override ...

?

Robby


On Thu, Aug 4, 2016 at 9:41 AM, Normal Loone  wrote:
> I tried
>
> (define/augment (execute-callback)
> ...)
>
> So I'd just use another additional function of mine when the run button is 
> used, but execute-callback is apparently not augmentable? At least I got an 
> error message stating that.
>
> Is there another function that you can modify?
>
> --
> 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] Run Button interaction

2016-08-04 Thread Normal Loone
I tried 

(define/augment (execute-callback)
...)

So I'd just use another additional function of mine when the run button is 
used, but execute-callback is apparently not augmentable? At least I got an 
error message stating that. 

Is there another function that you can modify?

-- 
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] How do I "make base"

2016-08-04 Thread Tim Brown

William, Stephen,

Thank you for your help. It seems that what I want to do is not an
appropriate use of the prepackaged source, and I am now progressing
using a git clone.

Thanks again,

Tim

On 03/08/2016 18:11, William J. Bowman wrote:

I always forget the build process when I'm hacking on Racket too and have to 
glare at the INSTALL file
for a while.
Maybe the INSTALL file has too much detail, or the wrong details, and the 
instructions get lost in it?

I always build a minimal install via `make PKGS=base in-place` from the 
top-level directory of the Racket
repo, then install everything else via `raco pkg install`.
Binaries, including raco, end up in `racket/racket/bin`.

--
William J. Bowman


On Wed, Aug 03, 2016 at 06:02:53PM +0100, Tim Brown wrote:

Here's hoping someone can answer this without too much (any) difficulty:

I have the Unix source in racket-6.6-src.tgz from the download page.
It's untarred into racket-6.6 . I want this because it has a superset
of the packages I'll eventually want in my installation.

If I:

  configure
  make
  make plain-install

I don't get a raco executable built.

On IRC, it was suggested that I do a `make base` -- which should get me
a raco capabale of pkg and setup. Problem is -- I can't find base as a
target.

It was also suggested that it is not in src/Makefile, instead:
"I'm usually in the top-level checkout dir", to quote stamourv.

A git clone later and I *still* don't have base in any makefile.

Folks... how do I either make base or get as minimal a racket
installation as I can with a capable raco?

Thanks in anticipation,

Tim

--
Tim Brown - t...@timb.net - +44(0)7771714159

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



--
Tim Brown - t...@timb.net - +44(0)7771714159

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