[racket-users] Given any list, group n number of sublists into a single list

2017-05-17 Thread Don Green
Racket code that could perform this list manipulation?
(every-n-lists-into-list  '())
(every-n-lists-into-list 1 '((1) (2))) ;=> '(((1) (2)))
(every-n-lists-into-list 2 '((1) (2) (3) (4))) ;=> '(((1) (2)) ((3) (4)))
(every-n-lists-into-list 3 '((1) (2) (3) (4)) (5) (6))) ;=> '(((1) (2) (3))
((4) (5) (6)))
Thanks
Don

-- 
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] Given any list, group n number of sublists into a single list

2017-05-17 Thread Matthew Butterick
`slice-at`

http://docs.racket-lang.org/sugar/index.html?q=slice-at#%28def._%28%28lib._sugar%2Flist..rkt%29._slice-at%29%29
 



> On May 17, 2017, at 3:56 PM, Don Green  wrote:
> 
> Racket code that could perform this list manipulation?
> (every-n-lists-into-list  '())
> (every-n-lists-into-list 1 '((1) (2))) ;=> '(((1) (2)))
> (every-n-lists-into-list 2 '((1) (2) (3) (4))) ;=> '(((1) (2)) ((3) (4)))
> (every-n-lists-into-list 3 '((1) (2) (3) (4)) (5) (6))) ;=> '(((1) (2) (3)) 
> ((4) (5) (6)))

-- 
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 a created language in the repl

2017-05-17 Thread Vityou
I made a little lambda-calculus language and it works for everything, except 
when I try to use it in the repl: racket -I lambda-calculus.  It acts like it 
worked, but when I try to type an expression it says that all the variables 
like #%top-interaction don't exist.  I made a pure language and a base (that 
just adds some stuff to pure) language, and in the main.rkt file, I made a 
reader submodule that just uses the base language: (module reader 
syntax/module-reader
  "base.rkt")

The repl works with lambda-calculus/base and pure, but not plain 
lambda-calculus.  Plain lambda-calculus works in the drracket interactions 
area, so I don't know why it won't work in the repl.

-- 
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] Given any list, group n number of sublists into a single list

2017-05-17 Thread George Neuner


Doing people's homework are we?

On 5/17/2017 8:08 PM, Matthew Butterick wrote:

`slice-at`

http://docs.racket-lang.org/sugar/index.html?q=slice-at#%28def._%28%28lib._sugar%2Flist..rkt%29._slice-at%29%29 



On May 17, 2017, at 3:56 PM, Don Green > wrote:


Racket code that could perform this list manipulation?
(every-n-lists-into-list  '())
(every-n-lists-into-list 1 '((1) (2))) ;=> '(((1) (2)))
(every-n-lists-into-list 2 '((1) (2) (3) (4))) ;=> '(((1) (2)) ((3) (4)))
(every-n-lists-into-list 3 '((1) (2) (3) (4)) (5) (6))) ;=> '(((1) 
(2) (3)) ((4) (5) (6)))




Very nice!  Unfortunately, the existence of sugar was unknown to me 
until just now.   More evidence that one can spend a lifetime learning 
what batteries Racket already has included.



My 1st thought was to use split-at:

#lang racket
(define (group-items n items)

  ;; check # of items
  (unless (= 0 (modulo (length items) n))
(error "not enough items"))

  ;; split and reassemble
  (let loop [
 (items  items)
 (result '())
]
(if [null? items]
(reverse result)
(let-values [((head tail)(split-at items n))]
  (loop tail (cons head result)))
))
  )

George

--
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 do you set the expander of a module to a module in the same file as the module whose expander you want to set

2017-05-17 Thread Vityou
If I have a module called reader, and I want to set its expander with 
syntax/module-reader to a module in the same file as reader, how would I do so? 
 I have tried submod, but apparently you can only use it in a require/provide 
statement.

-- 
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] using a created language in the repl

2017-05-17 Thread Alex Knauth

> On May 17, 2017, at 8:30 PM, Vityou  wrote:
> 
> I made a little lambda-calculus language and it works for everything, except 
> when I try to use it in the repl: racket -I lambda-calculus.  It acts like it 
> worked, but when I try to type an expression it says that all the variables 
> like #%top-interaction don't exist.  I made a pure language and a base (that 
> just adds some stuff to pure) language, and in the main.rkt file, I made a 
> reader submodule that just uses the base language: (module reader 
> syntax/module-reader
>  "base.rkt")
> 
> The repl works with lambda-calculus/base and pure, but not plain 
> lambda-calculus.  Plain lambda-calculus works in the drracket interactions 
> area, so I don't know why it won't work in the repl.

In general it depends on whether you need to change the reader or not. However 
from your reader module it looks like you're using the default reader, so most 
likely just re-providing racket's #%top-interaction from "base.rkt" will work.

Alex Knauth

-- 
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] using a created language in the repl

2017-05-17 Thread Vityou
I did reprovide all of the #%... forms from racket, and the repl works with 
base.rkt, it's when I have a reader that the repl doesn't work.

-- 
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] ANN: syntax-parse-example 0.0

2017-05-17 Thread Ben Greenman
The syntax-parse-example package is a showcase of useful macros written
using syntax-parse.
https://pkgs.racket-lang.org/package/syntax-parse-example

At the moment, the showcase is nearly empty ... but it's easy to contribute!

0. Design a beautiful macro, give it a name e.g. BOB
1. Run `raco pkg install --clone syntax-parse-example; cd
syntax-parse-example`
2. Run `raco syntax-parse-example --new BOB`. This generates a directory
and 3 files:
  - `BOB/BOB.rkt` : the macro goes here
  - `BOB/BOB-test.rkt` : for unit tests
  - `BOB/BOB.scrbl` : for documentation
3. Fill in the blanks in the new files, add `BOB` to the top-level file
`index.scrbl`.


Then, if you run `raco setup syntax-parse-example` it will render your
documentation on the page for the `syntax-parse-example` module.

- - -

Example doc:
http://docs.racket-lang.org/syntax-parse-example/index.html?q=syntax-parse-example#%28part._first-class-or%29

The doc's source:
https://github.com/bennn/syntax-parse-example/blob/master/first-class-or/first-class-or.scrbl

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