Re: [racket-users] Transforming data for plot / discreet-histogram

2016-06-07 Thread Ben Greenman
For now, you can use sequence-map to turn the hashtable into a sequence of vectors. #lang racket (require math) (require plot) (discrete-histogram (sequence-map vector (in-hash (samples->hash '(1 2 3 4 4) But it would be nicer if discrete-histogram took a hash as input. On Tue, Jun 7,

Re: [racket-users] Learning by doing Typed Racket

2016-06-12 Thread Ben Greenman
On Sun, Jun 12, 2016 at 9:53 PM, Daniel Prager wrote: > It seems that math libraries are a sweet-spot for TR. What else? > > The math library has to deal with all the same growing pains (inst, assert). I think part of the reason it looks so good is that it sparked

Re: [racket-users] Learning by doing Typed Racket

2016-06-12 Thread Ben Greenman
the list ... > > On Sun, Jun 12, 2016 at 4:56 PM, Ben Greenman <benjaminlgreen...@gmail.com > > wrote: > >> Yep, use `inst` to instantiate the polymorphic variables to sort. >> >> #lang typed/racket >> >> ((inst sort (List Symbol Integer) Integer) >

Re: [racket-users] Learning by doing Typed Racket

2016-06-11 Thread Ben Greenman
On Sat, Jun 11, 2016 at 12:46 AM, Daniel Prager wrote: > Do you have an alternative recommendation in mind? I guess you already solved this one, but for later it might help to avoid macros. -- You received this message because you are subscribed to the Google

Re: [racket-users] Learning by doing Typed Racket

2016-06-11 Thread Ben Greenman
start. > > I can see that staying clear of macros avoids an additional layer of > sophistication. > > Dan > > > On Sat, Jun 11, 2016 at 5:13 PM, Ben Greenman <benjaminlgreen...@gmail.com > > wrote: > >> >> On Sat, Jun 11, 2016 at 12:46 AM, Daniel Prager

Re: [racket-users] Proper handling for a custom current-read-interaction?

2016-06-08 Thread Ben Greenman
> > I believe that ocaml has a special ;; character in the language specially > for > handling situations like that. > Yep, similar to how Python looks for 2 consecutive newlines to end a block. (OCaml's ;; is sometimes useful in files, but those cases are very rare.

[racket-users] Re: Success! coloured text in a scribble document!

2016-05-26 Thread Ben Greenman
Yes, that's from scribble/manual. It's Racket's version number. Changing the first two lines of code to: #lang scribble/base @(require scribble/core) Removes the version number. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe

Re: [racket-users] WurstfagottCon

2016-06-22 Thread Ben Greenman
At first I thought these were torture instruments. On Wed, Jun 22, 2016 at 3:32 PM, 'John Clements' via Racket Users < racket-users@googlegroups.com> wrote: > So… I name some of my machines after medieval instruments. Crumhorn, > sackbut. Time for a new one. List of medieval instruments? Sure,

Re: [racket-users] interested in TR internal error?

2016-06-27 Thread Ben Greenman
Just got the same error in a different file, here's a small example. (If I call local-expand on a (cast ...) expression, seems I can't use that expression anymore -- but I can still use the expanded version) #lang typed/racket (require (for-syntax racket/base syntax/parse)) (define-syntax (f

Re: [racket-users] new user, simple question: cannot run simple example: (cons 1 2)

2016-05-23 Thread Ben Greenman
You are probably using a student language instead of #lang racket To fix put "#lang racket" at the top of your program or click the language button at the bottom-left of your Dr.Racket window and pick a non-teaching language. On Mon, May 23, 2016 at 1:47 PM, 'Leo Rokon' via Racket Users <

Re: [racket-users] trying to get pregenerated html into scribble

2016-05-22 Thread Ben Greenman
Try `include-template` from `web-server/templates` http://docs.racket-lang.org/web-server/templates.html#%28form._%28%28lib._web-server%2Ftemplates..rkt%29._include-template%29%29 (Maybe combined with `@literal` from `scribble/html`) Example: ;; static.html static content ;; main.scrbl #lang

[racket-users] Re: Puzzling success at getting pregenerated html into scribble

2016-05-22 Thread Ben Greenman
Whoops, I thought it would be easy to put raw HTML in a normal scribble document using @include-template[]. But I can't figure out how to do it. The trick I use for LaTeX is: @(make-element (make-style "relax" '(exact-chars)) "any$\tau$hing") and 'exact-chars doesn't work for HTML. Sorry for

[racket-users] Re: Puzzling success at getting pregenerated html into scribble

2016-05-22 Thread Ben Greenman
would work. But if you want to keep using scribble/html, here's a Makefile that I use to turn .rkt files into static .html pages: https://github.com/nuprl/gtp/blob/gh-pages/Makefile ]] On Sun, May 22, 2016 at 4:42 PM, Hendrik Boom <hend...@topoi.pooq.com> wrote: > On Sun, May 22, 2016 at 02

Re: [racket-users] Question on contracts -- check equal length of args

2016-07-15 Thread Ben Greenman
On Fri, Jul 15, 2016 at 12:31 PM, Matthias Felleisen wrote: > > On a separate question: How do I contribute to the docs? > > git pull requests on github are highly welcome. The easiest way to make a docs pull request is to: 1. Go to github.com, find the file you want to

[racket-users] sequence-append*

2016-07-18 Thread Ben Greenman
Hi, does anyone have an efficient `sequence-append*` function that takes a sequence of sequences and returns the sequence that has all elements from each, in order? Here is my version. It works, but I'm wondering if there's a better way. (require racket/generator) ;; (Sequenceof (Sequenceof A))

Re: [racket-users] How to dynamically generate top-level procedures?

2016-08-09 Thread Ben Greenman
Here's something in the ballpark. #lang racket (define-namespace-anchor nsa) (define ns (namespace-anchor->namespace nsa)) (let ((xyz 1)) (for ((name '(x y z))) (namespace-set-variable-value! name (lambda () (displayln (format "~a: ~a" name xyz)) (set! xyz (add1 xyz))) #f ns))) (eval

[racket-users] syntax -> normalized-arity

2016-08-09 Thread Ben Greenman
Does anyone have code for statically approximating the arity (and keywords) of a function? Examples of my dream function static-procedure-arity: > (static-procedure-arity #'(lambda (x) x)) 1 > (static-procedure-arity #'(lambda (x #:y y . z) x)) (arity-at-least 1) > (static-procedure-arity

[racket-users] Stickers!

2017-01-24 Thread Ben Greenman
Hi Racket Users, I ordered a bunch of Racket stickers to celebrate the 6.8 release. Here's proof: http://www.ccs.neu.edu/home/types/resources/stickers.jpg If you send me your address, I will mail you some stickers. For free!* I'm thinking 4 stickers per request (2 rectangles, 2 circles), but if

Re: [racket-users] Stickers!

2017-01-27 Thread Ben Greenman
gt; > that's a great idea. I'd like to order some at a local supplier for > distributing them in Germany/Europe. > > Are there any legal issues to consider? (I did not find anything in the > documentation.) > > Kind regards, > Daniel > > Am 24.01.2017 um 22:15 schrieb Be

Re: [racket-users] Confused about syntax properties

2017-01-29 Thread Ben Greenman
The third result is #f because in the third example, stx is `(annotate (annotate 4 2))`. So the first pattern matches and `val` is the syntax `(annotate 4 2)`. You can get a "strict" evaluation order by using `local-expand` inside the `annotate` macro. For example: #lang racket (define-syntax

Re: [racket-users] The Little Schemer, misprint?

2017-02-25 Thread Ben Greenman
The printed explanation is giving the meaning of the whole line (in the context of the call to member) --- not just the meaning of the application (null? lat) Hope this helps On Sat, Feb 25, 2017 at 11:17 AM, Kieron Hardy wrote: > I'm going through The Little Schemer

Re: [racket-users] Best way to ensure threads finish in GUI application?

2017-02-22 Thread Ben Greenman
Yep that's a typo. I've pushed a fix; thanks for reporting! https://github.com/racket/racket/commit/591d57b5bc11784b4d34860b26840ffe874bfb91 On Wed, Feb 22, 2017 at 10:36 PM, Vladimir Gajic wrote: > Is "(make-plumber) → pluber?" a typo in 14.11 Plumbers documentation?

Re: [racket-users] Why doesn't this maxval function correctly return the maximum value in the list

2017-02-13 Thread Ben Greenman
Here's a version of your code that runs in the Intermediate Student language ("local" isn't part of Beginning Student): (define (maxval lst) (local ((define (aux lst max) (cond [(null? lst) max] [(> (car lst) max) (aux (cdr lst) (car lst))]

Re: [racket-users] Serializing macro transformer procedures

2017-01-20 Thread Ben Greenman
I can do this in the normal Racket repl: (define (f x) (define-syntax-rule (rev-apply x g) (g x)) (rev-apply x add1)) (f 3) ;; ==> 4 I'd like to put a `(debug-repl)` inside the definition of `f` and call `rev-apply` in that debug repl too. On Fri, Jan 20, 2017 at 6:52 AM, Philip

Re: [racket-users] testing for timeout in Rackunit?

2016-08-18 Thread Ben Greenman
Also try `call-with-limits` from racket/sandbox http://docs.racket-lang.org/reference/Sandboxed_Evaluation.html#%28def._%28%28lib._racket%2Fsandbox..rkt%29._call-with-limits%29%29 On Thu, Aug 18, 2016 at 6:37 PM, Matthias Felleisen wrote: > > Do you mean something like

Re: [racket-users] Racket -script running other Racket scripts

2016-08-21 Thread Ben Greenman
I would use `system*` or `process*` with `(find-exe)` [1] as the first argument. You might also like `find-console-bin-dir` [2]. [1] http://docs.racket-lang.org/raco/exe.html#%28def._%28%28lib._compiler%2Ffind-exe..rkt%29._find-exe%29%29 [2]

Re: [racket-users] TR warning with pict3d-canvas% (in pict3d)

2016-09-08 Thread Ben Greenman
On Wed, Sep 7, 2016 at 10:35 AM, Tim Brown wrote: > ffi-types.rkt:19 is: > .. > 17 (require/typed > 18 ffi/unsafe > *19 [#:opaque CPointer cpointer?] ; includes Bytes and other things > that can be used as cpointers > 20 [#:opaque CType ctype?] > 21 ) > ..

Re: [racket-users] Re: Why is 3d3 a number?

2016-09-20 Thread Ben Greenman
Whew, fantastic! Thank you. (Should I tell the Fundamentals I students about R6RS?) On Tue, Sep 20, 2016 at 11:32 AM, Asumu Takikawa <as...@simplyrobot.org> wrote: > On 2016-09-20 11:27:07 -0400, Ben Greenman wrote: > >Oh! Just found that common lisp used these for types: >

[racket-users] Why is 3d3 a number?

2016-09-20 Thread Ben Greenman
Just confused, is there any reason that 'd' 'e' 'f' 's' 'l' are all accepted as exp-mark s? http://docs.racket-lang.org/reference/reader.html%20numbers#%28part._parse-number%29 Before I came here I asked Wolfram Alpha. It says: - 3d3 is probably "3 dice with 3 sides each" and prints a histogram

[racket-users] Re: Why is 3d3 a number?

2016-09-20 Thread Ben Greenman
Oh! Just found that common lisp used these for types: - s = short - f = single - d = double - l = long http://www.gigamonkeys.com/book/numbers-characters-and-strings.html Is this still true for Racket? On Tue, Sep 20, 2016 at 11:25 AM, Ben Greenman <benjaminlgreen...@gmail.com> wrote:

Re: [racket-users] optional hyphen in scibble

2016-10-02 Thread Ben Greenman
Maybe: https://pkgn.racket-lang.org/package/hyphenate On Sun, Oct 2, 2016 at 3:30 PM, Jos Koot wrote: > Hi to all of this nice list, > > IIRC I have seen a tool to put optional hyphens in running text in order > to allow scribble to break words at the end of a line. > >

Re: [racket-users] Contract violation where number expected - can't understand why

2016-10-01 Thread Ben Greenman
Maybe this will help: (struct interval (small big guesses)) creates 5 new functions 1. interval, for making intervals. For example (interval 5 10 0) creates an interval from 5 to 10 that has 0 guesses 2. interval?, for testing if a value is an interval. For example (interval? 1) is

Re: [racket-users] Creating a list of random things

2016-10-25 Thread Ben Greenman
Or: (build-list n (lambda (dont-care) (make-random-string))) On Tue, Oct 25, 2016 at 10:42 PM, Robby Findler wrote: > I would probably write that function like this: > > #lang racket > > (provide > (contract-out > [make-a-string (-> non-empty-string?

Re: [racket-users] Problem displaying a struct returned by a function in a cond statement

2016-10-26 Thread Ben Greenman
Can you show us findSense? The error message is saying there's an extra pair of parentheses somewhere, for example: > (1) > (define-struct foo () #:transparent) > ((foo)) On Wed, Oct 26, 2016 at 1:16 PM, Ken MacKenzie wrote: > New to racket and playing with a little

Re: [racket-users] POST requests never bound?

2016-11-08 Thread Ben Greenman
Here! https://github.com/racket/web-server/blob/master/web-server-doc/web-server/scribblings/dispatch.scrbl (If you install `raco-find-collection`, then running `raco fc web-server` should bring you close to the right place.) On Tue, Nov 8, 2016 at 4:38 PM, Luke wrote: >

Re: [racket-users] Of editors and mere mortals

2016-11-05 Thread Ben Greenman
Do you have racket-mode installed? https://github.com/greghendershott/racket-mode -- 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

Re: [racket-users] Re: FUSE filesystem package

2016-10-12 Thread Ben Greenman
> > > Any connection to Jesse's affine contracts? > > http://planet.racket-lang.org/package-source/tov/affine- > contracts.plt/2/2/planet-docs/manual/index.html Whoa, I didn't know those existed. Cool! -- You received this message because you are subscribed to the Google Groups "Racket Users"

Re: [racket-users] opinions on YAML as communication tool

2016-10-21 Thread Ben Greenman
I vote that you stick with Excel & change the version control protocol. Maybe: http://stackoverflow.com/a/17106035/5237018 On Fri, Oct 21, 2016 at 9:22 AM, Matthias Felleisen wrote: > > See Claire’s paper on cKanren. Scheduling is one of her examples (though > small

Re: [racket-users] raco pkg install failing inside Virtualbox. OpenSSL issue?

2016-10-19 Thread Ben Greenman
You can disable El Capitan's "system integrity protection". http://stackoverflow.com/questions/30768087/restricted-folder-files-in-os-x-el-capitan On Wed, Oct 19, 2016 at 1:09 PM, David Storrs wrote: > I have it on OSX running on metal. My understanding (possibly wrong)

[racket-users] ANN: with-cache

2016-11-22 Thread Ben Greenman
with-cache is a small package for saving the results of an expression to the filesystem #lang racket/base (require pict with-cache) (define (get-fish) (with-cache (cachefile "stdfish.rktd") (λ () (standard-fish 100 50 (get-fish) ;; Builds a fish (get-fish) ;; Reads a fish from

Re: [racket-users] Re: ANN: with-cache

2016-11-23 Thread Ben Greenman
frame% ...)' > > The object itself is essentially a collection of large (about 1 items) > vectors (about 30 of them) plus some metadata. > > Thanks, > Alex. > > On Wednesday, November 23, 2016 at 1:11:27 PM UTC+8, Ben Greenman wrote: > > with-cache is a small package f

Re: [racket-users] If a thunk is a proc of zero arguments, what is a proc of one argument?

2016-11-15 Thread Ben Greenman
On Tue, Nov 15, 2016 at 11:57 AM, David Storrs wrote: > I did not, but that's a very nice feature. Unfortunately, I'm an Emacs > guy. :/ Then you have no excuse for not making a λ macro. -- You received this message because you are subscribed to the Google Groups

Re: [racket-users] syntax-class that is just a set of literals

2016-11-18 Thread Ben Greenman
Typo: I meant "the `define-literal-syntax-class` macro", from here: https://groups.google.com/d/msg/racket-users/9e_oNlLODeY/MUqGM_r6BwAJ On Fri, Nov 18, 2016 at 7:03 PM, Ben Greenman <benjaminlgreen...@gmail.com> wrote: > > On Wed, Nov 16, 2016 at 6:05 PM, D

Re: [racket-users] syntax-class that is just a set of literals

2016-11-18 Thread Ben Greenman
On Wed, Nov 16, 2016 at 6:05 PM, Dan Liebgold wrote: > First, I'm trying to define a syntax-class that is just a set of literals, > and I'm wondering if there is a slightly better way that this: > > * http://pasterack.org/pastes/86722 > > I'd just prefer to not

Re: [racket-users] docs for string-trim

2016-11-01 Thread Ben Greenman
The trick is that 'whitespace' isn't just #\space. It's any sequence of whitespace characters, like "\r\r\r" or " \r\n\t" On Wed, Nov 2, 2016 at 12:12 AM, wrote: > Hi, > > when using the search function for the Racket-docs > with string-trim I found: > > - >

Re: [racket-users] Unable to utilize parse-command-line to build command line application

2016-10-11 Thread Ben Greenman
Indirect answer: could you use `command-line` instead? #lang racket/base (require racket/cmdline) (define input-from (make-parameter #f)) (command-line #:program "sample" #:once-each [("-i" "--input-file") i "Use as the input file." (input-from i)] #:args (file) (printf "my

[racket-users] How to edit the htdp package from a release?

2016-10-12 Thread Ben Greenman
I've installed Racket 6.6 from download.racket-lang.org and I'd like to submit a change to the HTDP repo. (This question is not really specific to HTDP, anyway) Before I submit the edit, I want to test the change on my machine, so I figure I'll make a clone of the htdp package: $ raco pkg

Re: [racket-users] Unable to utilize parse-command-line to build command line application

2016-10-12 Thread Ben Greenman
tho...@me.com> wrote: > On Wednesday, October 12, 2016 at 6:54:45 AM UTC-4, Ian Thomas wrote: > > On Tuesday, October 11, 2016 at 9:50:12 PM UTC-4, Ben Greenman wrote: > > > Indirect answer: could you use `command-line` instead? > > > > > > > > > >

Re: [racket-users] How to edit the htdp package from a release?

2016-10-12 Thread Ben Greenman
yes yes yes Thank you! On Wed, Oct 12, 2016 at 12:01 PM, Matthew Flatt <mfl...@cs.utah.edu> wrote: > At Wed, 12 Oct 2016 11:34:06 -0400, Ben Greenman wrote: > > I've installed Racket 6.6 from download.racket-lang.org and I'd like to > > submit a change to the HTDP repo. &

Re: [racket-users] ->i applies contract projections multiple times?

2016-12-15 Thread Ben Greenman
There are 3 parties that could be blamed: 1. the context that calls `foo` 2. the function `foo` 3. the contract on `foo` On Thu, Dec 15, 2016 at 5:05 PM, Alexis King wrote: > Many thanks to both of you for the explanation and examples. I admit > I’ve seen that paper

Re: [racket-users] Good Data Structures Book?

2016-12-13 Thread Ben Greenman
"Purely Functional Data Structures" https://www.amazon.com/Purely-Functional-Structures-Chris-Okasaki/dp/0521663504 On Tue, Dec 13, 2016 at 1:22 PM, Lawrence Bottorff wrote: > Can someone suggest a good text for data structures that would compatible > with Racket? All I see

Re: [racket-users] Syntax for hash contracts

2016-12-02 Thread Ben Greenman
On Thu, Dec 1, 2016 at 7:29 PM, David Storrs wrote: > I'm having trouble understanding the docs on hash contracts ( > https://docs.racket-lang.org/reference/data-structure- > contracts.html#%28def._%28%28lib._racket%2Fcontract% > 2Fprivate%2Fhash..rkt%29._hash%2Fc%29%29)

Re: [racket-users] sxml pkg install

2017-01-03 Thread Ben Greenman
Run `raco pkg install sxml` and use `(require sxml)`. On Tue, Jan 3, 2017 at 1:54 PM, Robert Kirkpatrick < robert.kirkpatrick...@gmail.com> wrote: > Newbie question: > I can't find a way to install a sxml pkg (require (planet sxml)) > TIA, > Robert. > > -- > You received this message because you

Re: [racket-users] Dynamically generated keywords -- are they possible?

2017-01-09 Thread Ben Greenman
You can use it with keyword-apply (define (foo #:x x) (+ x 3)) (keyword-apply foo (list (string->keyword "x")) (list 8) '()) ;; ==> 11 http://docs.racket-lang.org/reference/procedures.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._keyword-apply%29%29 On Mon, Jan 9, 2017 at 12:47 PM,

Re: [racket-users] Re: Stickers!

2017-03-28 Thread Ben Greenman
Sure. What's your mailing address? On Tue, Mar 28, 2017 at 4:55 AM, Adeoluwa Adejumo <adejumoadeol...@gmail.com > wrote: > On Tuesday, 24 January 2017 22:15:59 UTC+1, Ben Greenman wrote: > > Hi Racket Users, > > > > > > I ordered a bunch of Racket stickers to ce

Re: [racket-users] change 'random' contract to allow zero in first position?

2017-03-03 Thread Ben Greenman
https://github.com/racket/racket/pull/1626 -- 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

[racket-users] Racket t-shirts and stickers on DevSwag

2017-03-08 Thread Ben Greenman
Racket stickers and t-shirts are now on devswag.com - https://devswag.com/products/racket - https://devswag.com/products/racket-t-shirt Looking for a last-minute St Patrick's Day gift? Or a Fathers' Day gift for the Racketeer that has it all? Then LOOK NO FURTHER! (Half the proceeds from

Re: [racket-users] defstruct* fails for a (long long long) long struct name

2017-03-11 Thread Ben Greenman
Adding a field also fixes the problem: #lang scribble/manual @require[@for-label[racket]] @defstruct*[(abcdefghijklmnopqrstuvwxyzABCDEEFGHIJKLMNOPQRSTUVWX-Z ABCD) ([hi integer?])]{} and the problem has to do with how `defstruct*` renders the first line of a struct declaration. If the struct

Re: [racket-users] Typed Racket: Polymorphic function `dynamic-wind' could not be applied to arguments

2017-03-06 Thread Ben Greenman
On Mon, Mar 6, 2017 at 1:18 AM, kay wrote: > Looks like it might be worth mentioning somewhere in the documentation Good idea, what do you think of this change: https://github.com/racket/typed-racket/pull/508 -- You received this message because you are subscribed to the

Re: [racket-users] range with small or zero step doesn't return

2017-04-17 Thread Ben Greenman
Maybe, just add a note to the docs? On Mon, Apr 17, 2017 at 4:56 PM, Vincent St-Amour < stamo...@eecs.northwestern.edu> wrote: > The latter is easy to fix; I've submitted a pull request. > > The former is trickier. The problem is not so much due to the step size > itself, but rather to a

Re: [racket-users] Running a program in multiple languages at once

2017-08-13 Thread Ben Greenman
One idea: - write your program just like that, `1 + 2` with no #lang line, - run your program with a raco command that runs the program once for each language Something like `raco mystery-lang -L lang1 -L lang2 -L lang3 file.txt` In case you need an example raco-command:

Re: [racket-users] ?

2017-07-16 Thread Ben Greenman
Maybe related: https://groups.google.com/forum/#!topic/racket-users/6fKGky4tud8 On Sun, Jul 16, 2017 at 8:26 AM, Philip McGrath wrote: > Could you share the code that is producing the error? The following, for > example, defines a struct with two fields: > > (struct

Re: [racket-users] Scribble: tables and figures with captions and numbering?

2017-07-06 Thread Ben Greenman
You can assign numbered captions to figures with `figure` from `scriblib/figure` (and reference them with `figure-ref`). http://docs.racket-lang.org/scriblib/figure.html I don't know how to caption tables or number equations in Scribble. On Thu, Jul 6, 2017 at 7:50 AM, Dmitry Pavlov

Re: [racket-users] Scribble PDF output breaks when using include-section with scribble/lp2

2017-07-14 Thread Ben Greenman
> > Especially oddly, running scribble with --latex and then manually making > the PDF works, except that the table of contents is blank. > Check if it works when you make the PDF twice. This sounds like it's trouble resolving cross references. Maybe there's a bad character in a label [1], maybe

Re: [racket-users] Example of file i/o?

2017-07-18 Thread Ben Greenman
(with-input-from-file "file.txt" (lambda () (for ((line (in-lines))) ))) On Tue, Jul 18, 2017 at 12:46 PM, Leith wrote: > Basic question, but I can't seem to find a good answer. What is an > example of "idiomatic" file I/O using racket? Like, for example,

Re: [racket-users] Getting the phases right on recursive macros/using ... at runtime in syntax-case

2017-07-18 Thread Ben Greenman
3 hints: - `type-check` can call any helper functions defined with `define-for-syntax` - Turnstile uses `local-expand` to expand any macros in subterms (in your case, any macros in `x` and `y`) - start using `syntax-parse` :) On Tue, Jul 18, 2017 at 6:11 PM, Matthias Felleisen

Re: [racket-users] A bug in the Typed Racket system?

2017-07-21 Thread Ben Greenman
Type inference is failing you again. If you instantiate `foo/s`, you get the type you expect: #lang typed/racket (struct (a) Foo ([val : (-> a a)])) (: foo/s (All (a b) (-> (-> a b) (-> (Foo a) (Foo b) (Foo b)

Re: [racket-users] Racket7 Conceit

2017-07-19 Thread Ben Greenman
mflatt answered some "why"s on the racket-dev list: https://groups.google.com/d/msg/racket-dev/2BV3ElyfF8Y/4RSd3XbECAAJ On Thu, Jul 20, 2017 at 12:34 AM, Lehi Toskin wrote: > I've read through a few README's in the racket7 repo and I can't find > anything specifically

Re: [racket-users] Proper non-tail recursion?

2017-04-28 Thread Ben Greenman
On Fri, Apr 28, 2017 at 11:08 AM, Daniel Bastos wrote: > interview done with Guido van Rossum http://neopythonic.blogspot.com/2009/04/tail-recursion-elimination.html Related: lexical scope is interesting *theoretically*, but its inefficient to > implement; dynamic scope

Re: [racket-users] Proper non-tail recursion?

2017-04-28 Thread Ben Greenman
Right ... it's about "growable stack languages" or "infinite stack languages" or "heapful languages" or something like that. On Fri, Apr 28, 2017 at 11:29 AM, Matthias Felleisen <matth...@ccs.neu.edu> wrote: > > > On Apr 28, 2017, at 11:12 AM, Ben G

[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

Re: [racket-users] Is it possible with Scrible's @hyperlink, to open the linked document in a new webpage?

2017-06-21 Thread Ben Greenman
#lang scribble/manual @require[ (only-in scribble/core style) (only-in scribble/html-properties attributes)] @(define new-window-style (style #f (list (attributes '((target . "_blank")) @hyperlink[#:style new-window-style "https://www.racket-lang.org"]{Racket} On Tue, Jun 20, 2017

Re: [racket-users] immutable hash table performance

2017-05-25 Thread Ben Greenman
Is the y-axis on the first plot labeled correctly? It's reporting fractions of a millisecond, but the text talks about 7 vs. 40 seconds. Also the timings links aren't working for me: https://www.brinckerhoff.org/img/hash-table-timings.rkt

Re: [racket-users] How to discard an unknown number of (values) return?

2017-05-16 Thread Ben Greenman
Try `(call-with-values func void)` http://docs.racket-lang.org/reference/values.html#%28def._%28%28quote._~23~25kernel%29._call-with-values%29%29 On Tue, May 16, 2017 at 5:56 PM, David Storrs wrote: > I have a macro that wraps a function call in some debugging

Re: [racket-users] Re: Stickers!

2017-06-08 Thread Ben Greenman
com> wrote: > On Tuesday, January 24, 2017 at 10:15:59 PM UTC+1, Ben Greenman wrote: > > Hi Racket Users, > > > > > > I ordered a bunch of Racket stickers to celebrate the 6.8 release. > Here's proof: > > http://www.ccs.neu.edu/home/types/resources/sticke

Re: [racket-users] Help needed to fix type error

2017-06-05 Thread Ben Greenman
Maybe the issue is line 52 of math/private/distributions/utils (it seems like a typo to me) (define-type type-name (struct-name Real Flonum)) I think this means that the type Discrete-Uniform-Dist is really (discrete-uniform-dist-struct Real Flonum). Anyway, if I change the return typed of

Re: [racket-users] Wanted: Easier way to contribute docs

2017-06-13 Thread Ben Greenman
> > This is a nice idea, though possibly complicated to implement (AFAICT it > would require annotating the HTML of a given part of the documentation with > a reference to the source code that originally generated it, and in a way > that can be generalized to every Racket project, not just the

Re: [racket-users] Function contract that cares only about the return value?

2017-06-13 Thread Ben Greenman
unconstrained-domain-> http://docs.racket-lang.org/reference/function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._unconstrained-domain-~3e%29%29 On Tue, Jun 13, 2017 at 11:24 AM, David Storrs wrote: > Suppose the following trivial function: > >

Re: [racket-users] Self evaluating Racket Interpreter

2017-05-01 Thread Ben Greenman
'(1 2 3) is short for (list 1 2 3) which is short for (cons 1 (cons 2 (cons 3 null)) which is different from (mcons 1 (mcons 2 (mcons 3 null))) I hope this helps On Mon, May 1, 2017 at 1:03 PM, wrote: > I posted this question on stackoverflow but have not found an

Re: [racket-users] Apropos contracts: simple predicates and switching on and off

2017-05-02 Thread Ben Greenman
On Tue, May 2, 2017 at 11:43 PM, Daniel Prager wrote: > I kind of expected that it would be possible to do what I wanted with > "indy" contracts, but struggled with the heavy use of combinators in the > examples. Two offhand thoughts: 1. To practice with dependent

Re: [racket-users] Apropos contracts: simple predicates and switching on and off

2017-05-04 Thread Ben Greenman
On Thu, May 4, 2017 at 8:23 PM, Dupéron Georges wrote: > In these cases, instead of turning off the contract checks altogether, it > would be nice to have a way to disable the define/contract and turn it into > a contract-out, using a single parameter (perhaps a

Re: [racket-users] Built-in way to list all children of a directory?

2017-06-27 Thread Ben Greenman
The predicate can be any function. All files: `(find-files (lambda (x) #true) start-path)` All pdf files: `(find-files (lambda (x) (equal? #".pdf" (path-get-extension x))) some-path)` There's also the `file/glob` module. All pdf files: `(glob (build-path some-path "**" "*.pdf"))` Iterator for

Re: [racket-users] Re: code reflection

2017-10-16 Thread Ben Greenman
> Greg, if you're reading this...any chance you might expand FoM? In the meantime, the "Syntax Parse Examples" package is always accepting contributions: http://docs.racket-lang.org/syntax-parse-example/index.html#%28part._.The_.Examples%29 -- You received this message because you are

Re: [racket-users] European Racketeers and conferences

2017-10-17 Thread Ben Greenman
Here's a map to some cities where some Racket users are located: https://drive.google.com/open?id=1i3zN11e_6te5ytduAiv1cidrIi4=sharing -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails

Re: [racket-users] Redex v6.4 "broke" LambdaJS

2017-09-06 Thread Ben Greenman
I think it'll work if you delete the underscores, e.g. change "e_1" to "e1". On Wed, Sep 6, 2017 at 2:22 PM, wrote: > (For some reason the mail I sent to usersracket-lang.org last week > never made it to the Google Group, so I'm posting directly...) > > Hello, > > I'm a

Re: [racket-users] repeated code in interactions of scribble

2017-09-23 Thread Ben Greenman
You can re-use helper functions by running the different example blocks with the same evaluator (example below). I don't know how to hyperlink one interaction to another. - - - #lang scribble/manual @require[scribble/example] @(define my-eval (make-base-eval)) Beginning. @examples[#:eval

Re: [racket-users] document as fn from strings to HTML/text

2017-09-28 Thread Ben Greenman
Yes, you can use scribble/html to define functions from lists to documents. For example, this scribble file calls a function to build an ` ... ` page: https://github.com/nuprl/gtp/blob/gh-pages/about.rkt and here's the function: https://github.com/nuprl/gtp/blob/gh-pages/templates.rkt#L124 --

Re: [racket-users] scribble newbie, myfunctionname undefined

2017-09-28 Thread Ben Greenman
Try adding `#:eval foo-eval` to `interaction`. (I'm guessing that would work.) I'm more sure this will work: #lang scribble/manual @(require scribble/example "../main.rkt") ... @(define foo-eval (make-base-eval '(require "../main.rkt"))) @examples[#:eval foo-eval #:label #f (magic)

Re: [racket-users] Racket documentation formats

2017-09-29 Thread Ben Greenman
You can download PDFs for most of the documentation here: http://download.racket-lang.org/all-versions.html And if your device has Racket installed, you can run `raco docs` to view a local copy of the HTML. -- You received this message because you are subscribed to the Google Groups "Racket

Re: [racket-users] Fwd: Racket Con

2017-10-05 Thread Ben Greenman
I have 1 mug (unused) that still needs a home. On Thu, Oct 5, 2017 at 3:18 PM, 'John Clements' via users-redirect < us...@plt-scheme.org> wrote: > Forwarded without comment… :) > > Begin forwarded message: > > *From: *Jasmine Harihar Patel > *Subject: **Racket Con* >

Re: [racket-users] European Racketeers and conferences

2017-10-17 Thread Ben Greenman
I just changed the map settings so anyone can edit it. If you'd like to add your city to the map: 1. Look for "racketeers.csv" in the menu 2. Click the "vertical dots" to the right of "racketeers.csv". (If you hover the mouse over these dots, it should say "Layer Options") 3. Click "Open Data

Re: [racket-users] Include Documentation from a scribble/lp2 File: "identifier `doc' not included [...]" Error

2017-11-29 Thread Ben Greenman
Try changing the include-section to import the `doc` submodule: @include-section[(submod "sub-scribble.rkt" doc) I got this idea from the 2nd paragraph of the "scribble/lp2 language" docs: http://docs.racket-lang.org/scribble/lp.html#%28mod-path._scribble%2Flp2%29 On Wed, Nov 29, 2017 at 7:15

Re: [racket-users] Plot - Choosing the number of mesh lines independently from the number of samples

2017-11-29 Thread Ben Greenman
I don't think this is currently possible. To implement this, I think the `for-2d-sample` loop here needs to change: https://github.com/racket/plot/blob/master/plot-lib/plot/private/plot3d/surface.rkt#L28 (I guess there should be 2 loops, one to draw the surface and one to draw the lines) On

[racket-users] or/c, parametric->/c, and contract-first-order-passes?

2017-11-28 Thread Ben Greenman
The other day, I wanted to write a contract for a function that takes any kind of vector and does something depending on whether the vector is mutable. The contract was basically the one below: ``` #lang racket (define/contract (f v) (parametric->/c [A] (-> (or/c (vectorof A #:immutable

Re: [racket-users] Include Documentation from a scribble/lp2 File: "identifier `doc' not included [...]" Error

2017-11-29 Thread Ben Greenman
> * Would have never been able to deduce this from the info you referenced... Good point. Here's a pull request for changing the docs: https://github.com/racket/scribble/pull/154 -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe

Re: [racket-users] misterious empty line

2017-11-26 Thread Ben Greenman
My guess is that "(define" does something special to figure out where to insert newlines in the rendered document. On Thu, Nov 23, 2017 at 9:13 AM, Jos Koot wrote: > My code: > > #lang scribble/manual > > @(require > scribble/core > scribble/eval > racket >

Re: [racket-users] Advantage of ->d over ->i

2017-12-01 Thread Ben Greenman
Let me make sure I understand: 1. A converter is like a two-way function, lets say (A . <-> . B) 2. If someone composes two incompatible converters, like (integer? . <-> . symbol?) and (string? . <-> . boolean?) then they should get an error that points to the place where they tried to do the

Re: [racket-users] Raising arbitrary errors in Typed Racket

2017-12-01 Thread Ben Greenman
The error is because type signature of `raise` doesn't allow "non-flat" values like functions and mutable vectors. It might not be safe to allow `(raise (vector 1 2 3))` in Typed Racket ... I'm not sure. For now I think you should make a new exception type. Example: ``` #lang typed/racket/base

Re: [racket-users] Raising arbitrary errors in Typed Racket

2017-12-01 Thread Ben Greenman
That name sounds good to me. -- 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

Re: [racket-users] Interaction of Typed Racket with define/match?

2017-11-17 Thread Ben Greenman
> Others: Does define/match do anything that would make Typed Racket see it > differently from define + match*? It seems like define/match expands to > define + match*/derived anyway. The only thing that's different is which > define it's expanding to. So is expanding to Racket's define instead of

  1   2   3   >