Re: [racket-users] Breaking change to package 'handy'

2018-04-24 Thread Matthew Butterick
> On Apr 24, 2018, at 9:38 AM, David Storrs wrote: > > On Tue, Apr 24, 2018 at 12:09 PM, David Storrs > wrote: >> On Tue, Apr 24, 2018 at 11:11 AM, Vincent St-Amour >> wrote: >>> FWIW, this `multi-partition` sounds a lot like the built-in `group-by`. >> >> It ha

Re: [racket-users] Regexp question matching a whole string

2018-04-22 Thread Matthew Butterick
> On Apr 22, 2018, at 1:40 PM, Zelphir Kaltstahl > wrote: > > Ah OK, I understand that additional newline. Since the code matching the > regex is run before that newline gets in, the newline will be on the > input port. > > In DrRacket I observe the following: > > (I remembered that there are

Re: [racket-users] How to obtain the public IP of the sender of an HTTP request?

2018-04-17 Thread Matthew Butterick
PS if you're running the Racket web server as a proxy behind Apache, then `request-client-ip` will always be the localhost IP. However, Apache stores the original request IP in special header called X-Forwarded-For [1] which can be retrieved like so: (dict-ref (request-headers req) 'x-forwarded

Re: [racket-users] how to match unbound identifier as literal in `syntax-parse`?

2018-04-03 Thread Matthew Butterick
> On Apr 3, 2018, at 4:37 AM, Ryan Culpepper wrote: > > Here's one way: > > (~and z:id > (~fail #:unless (free-identifier=? #'z #'zeta) > "expected the identifier `zeta`")) > > Another way is to make a syntax class (either specifically for `zeta` or > parameterized by the

[racket-users] how to match unbound identifier as literal in `syntax-parse`?

2018-04-02 Thread Matthew Butterick
Consider the difference in results below. How would I persuade `syntax-parse` to match literal identifiers in the `free-identifier=?` sense that `syntax-case` does? (and thereby allow unbound identifiers to be compared also) IIUC, `#:literals` is too strict, as it insists that every listed ident

[racket-users] Re: Why is there a space in the path to the Racket application on MacOSX?

2018-03-30 Thread Matthew Butterick
On Thursday, March 29, 2018 at 12:51:07 PM UTC-7, Stephen Smith wrote: > > Authoring a new Racket book (targeting all platforms and non-programmers) > > Great idea! Are there more details you can share about the project? -- You received this message because you are subscribed to the Google Grou

Re: [racket-users] Output Port Shenanigans

2018-03-14 Thread Matthew Butterick
> On Mar 13, 2018, at 8:50 AM, Lehi Toskin wrote: > > There must be something I'm missing, but there's not much in the docs that > would help me. Just a guess, but this kind of double-dipping on ports is usually not possible, because once bytes are read from a port, they're gone. If you want

[racket-users] is there a name for the class of magic #% macros?

2018-02-25 Thread Matthew Butterick
Like `#%top` and `#%app` and `#%datum` and `#%module-begin`. Writing about them on Beautiful Racket, I called them "implicit forms". But maybe there's an existing term. [1] https://beautifulracket.com/explainer/implicit-forms.html --

Re: [racket-users] Generating automatic testsuites using a macro

2018-02-23 Thread Matthew Butterick
> On Feb 23, 2018, at 5:11 AM, 'Paulo Matos' via Racket Users > wrote: > > This fails because the i in the body of the test case does not exist at > run-time. I understand why this is failing. However if I try to replace > the i by #,(syntax->datum #'i) it also fails. My feeling is that I need

Re: [racket-users] Making print act like display

2018-02-17 Thread Matthew Butterick
Perhaps `display-to-file`? #lang racket (require racket/file) (define (write-to-file path string-list) (for ([line string-list]) (display-to-file line path #:exists 'append))) > On Feb 17, 2018, at 9:56 AM, Zelphir Kaltstahl > wrote: > > > I am writing to a file using the followin

Re: [racket-users] Quick regexp question

2018-02-02 Thread Matthew Butterick
> On Feb 2, 2018, at 10:23 AM, 'John Clements' via Racket Users > wrote: > > This macro gets the names in much closer to the corresponding patterns than > matching by index, but it doesn’t actually embed the names into the regexp. If you like keeping the names and patterns together, you coul

Re: [racket-users] whither `splicing-parameterize`? or am I doing it wrong?

2018-01-23 Thread Matthew Butterick
> On Jan 22, 2018, at 7:22 PM, Matthew Flatt wrote: > > I think I've never considered `splicing-parameterize` because > parameters can be mutated, but a `splicing-parameterize` form does make > sense. I imagine that it would be implemented by creating a > parameterization once, then pushing the

[racket-users] whither `splicing-parameterize`? or am I doing it wrong?

2018-01-21 Thread Matthew Butterick
I have a macro that produces code for a module expression, roughly like so: #'(module mod racket/base . BODY-EXPRS) I'd like to `parameterize` the BODY-EXPRS as a group, roughly like so: #'(module mod racket/base (parameterize ([param val]) . BODY-EXPRS)) But — my BODY-EXPRS migh

Re: [racket-users] What is the right way to generate HTML from the web server?

2018-01-04 Thread Matthew Butterick
> On Jan 4, 2018, at 11:47 AM, Jay McCarthy wrote: > > FWIW, txexpr is essentially just `xexpr->string` but it sees when you > put in a `script` or `style` and it puts the `make-cdata` for you. (It > also does a bit more checking to make sure the xexpr is well-formed.) For anyone curious why

Re: [racket-users] beautiful racket: trying a first dsl of my own

2017-12-29 Thread Matthew Butterick
> On Dec 29, 2017, at 3:31 PM, Robert Girault > wrote: > > (define-macro (prelude/connect-to HOST PORT) > #'(begin > (require racket/tcp) > (require racket/port) > (define-values (input-port output-port) > (tcp-connect HOST PORT

Re: [racket-users] Byte Order Mark: alter display of symbols containing nonprinting characters?

2017-12-28 Thread Matthew Butterick
> On Dec 27, 2017, at 10:15 PM, 'John Clements' via Racket Users > wrote: > > Again, there may be a reason why this is a bad idea, but I don’t think I’ve > heard it yet :). Speaking as a user of nonprinting characters, I expect them to, you know, not print ;) > People may need to learn t

[racket-users] Re: how can I approximate syntax properties with `make-rename-transformer`?

2017-11-29 Thread Matthew Butterick
icular reason `mb` and > `other-module-begin` need to communicate with syntax properties? > > On Tuesday, November 28, 2017 at 7:15:50 PM UTC-8, Matthew Butterick wrote: >> >> I'm making a #%module-begin macro, but I want to delegate it to an >> existing one. >>

[racket-users] how can I approximate syntax properties with `make-rename-transformer`?

2017-11-28 Thread Matthew Butterick
I'm making a #%module-begin macro, but I want to delegate it to an existing one. OK, let's start with a rename transformer: (provide (rename-out [mb #%module-begin])) (define-syntax mb (make-rename-transformer #'other-module-begin)) (define-syntax other-module-begin (λ (stx) #'foo)) That works

Re: [racket-users] minor proposed update to docs typography

2017-11-21 Thread Matthew Butterick
> On Nov 21, 2017, at 3:32 AM, Robby Findler > wrote: > > That may have been done that way to make the docs.racket-lang.org > page look better (to draw your eye to the > right manual). I figured. But hard-coding formatting inside `title` is a blunt instrument

Re: [racket-users] minor proposed update to docs typography

2017-11-20 Thread Matthew Butterick
> On Nov 20, 2017, at 6:10 PM, Greg Hendershott > wrote: >>> >> >> The following example hack _seems_ to clear the "impervious" hurdle? >> >> a.Sq span { font-weight: normal !important} >> >> I'm not a CSS guru. This barely clears the "it works" hurdle. >> That is, I don't know if the "Sq"

Re: [racket-users] minor proposed update to docs typography

2017-11-20 Thread Matthew Butterick
On Monday, November 20, 2017 at 7:59:40 AM UTC-8, Jens Axel Søgaard wrote: > > IPad Pro small landscape chrome. > Thanks, the iOS display problem is now fixed. On Monday, November 20, 2017 at 11:10:41 AM UTC-8, Daniel Prager wrote: > > Hi Matthew > > It looks very nice, but as a side effect s

[racket-users] minor proposed update to docs typography

2017-11-19 Thread Matthew Butterick
http://mbutterick.github.io/racket-doc-redo/doc/ This link demos some small typographic updates to the docs: + new title font (that matches the one used on other Racket websites) + new monospaced font (that matches the subhead font) + some techn

Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-11 Thread Matthew Butterick
On Nov 11, 2017, at 10:07 AM, Matthew Butterick wrote: > >> On Nov 11, 2017, at 8:17 AM, Robby Findler > <mailto:ro...@eecs.northwestern.edu>> wrote: >> >> There is definitely a tension here, but my experience >> suggests that it would not be a good use

Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-11 Thread Matthew Butterick
> On Nov 11, 2017, at 8:17 AM, Robby Findler > wrote: > > There is definitely a tension here, but my experience > suggests that it would not be a good use of my time to do something > like that. At least, not without a clear pain point in my own mind. > Since you see to have one of those, howe

Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-09 Thread Matthew Butterick
I see your point. But this technique forfeits any broader compatibility with desktop-oriented tools (e.g., file launchers and whatnot) I did try making an Automator application containing a shell script that simply launches DrRacket, and also tried `bash -c ···` (to try to force it to launch fr

Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-08 Thread Matthew Butterick
>> In this case I was trying to configure a web servlet to run in differently >> when launched from DrRacket (in terms of its port and servlet-path) to >> better >> approximate Apache / htaccess conditions that exist on the live web server. > > I wonder whether a submodule is a better approach

Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-08 Thread Matthew Butterick
> On Nov 8, 2017, at 9:17 AM, Matthew Flatt wrote: > > DrRacket tries not to interfere with programs in a detectable way. Hmm ... so if DrRacket adopts a different set of environment variables from command-line `racket` — which I assume is the correct and just policy — isn't that naturally go

[racket-users] where does DrRacket get its environment variables on OS X?

2017-11-08 Thread Matthew Butterick
The `(current-environment-variables)` visible in command-line `racket` seem to be exactly what I see when I just do `env` in the shell. Makes sense. But the `(current-environment-variables)` in DrRacket differ quite a bit: some are the same, some different, some missing, some new. 1) Where does

[racket-users] what are hash impersonators good for?

2017-11-04 Thread Matthew Butterick
Every time I think I have a good use for hash impersonators, it turns out they don't work the way I expect. So I'll invert the question: in what situation is a hash impersonator the best tool for the job? (Or, have they been eclipsed by other language features like `gen:dict`?) IIUC, `imper

Re: [racket-users] `raco pkg install` from private GitHub repo?

2017-10-29 Thread Matthew Butterick
Oct 25, 2017, at 6:50 PM, Jay McCarthy wrote: > > Mmm, that SHOULD be the same code path as what `raco pkg` is using. > Could you plop an eprintf on this line and see what arguments `raco > pkg` is giving `git-checkout` and we can see what code is at fault? > > https://github

Re: [racket-users] `raco pkg install` from private GitHub repo?

2017-10-26 Thread Matthew Butterick
FWIW for this command: raco pkg install https://github.com/mbutterick/app.git The exception is `exn:fail:user` ("raco pkg install: Git checkout initial protocol failed; the given URL might not refer to a Git repository") And for this command: raco pkg install http://github.com/mbutterick/a

[racket-users] how to configure travis to test `framework` on v6.0 & v6.1?

2017-10-25 Thread Matthew Butterick
I had to add `framework` as a dependency to `pollen`. I updated my travis config with these lines, which I know are needed for running `racket/gui` tests: before_install: - "export DISPLAY=:99.0" - "sh -e /etc/init.d/xvfb start" But on v6.0 and v6.1 that's not good enough. I get this error:

Re: [racket-users] `raco pkg install` from private GitHub repo?

2017-10-25 Thread Matthew Butterick
need to fiddle with the second to last argument. > > On Tue, Oct 24, 2017 at 6:00 PM, Matthew Butterick wrote: >> PS Same behavior on Ubuntu 14.04 or Mac OS 10.12.6, using Racket 6.10.1 in >> both cases. >> >> >> On Oct 24, 2017, at 2:57 PM, Matthew Butter

Re: [racket-users] `raco pkg install` from private GitHub repo?

2017-10-24 Thread Matthew Butterick
PS Same behavior on Ubuntu 14.04 or Mac OS 10.12.6, using Racket 6.10.1 in both cases. > On Oct 24, 2017, at 2:57 PM, Matthew Butterick wrote: > > Things seem to be on the right track, and then fail: > > Querying Git references for app at http://github.com/mbutterick/a

Re: [racket-users] `raco pkg install` from private GitHub repo?

2017-10-24 Thread Matthew Butterick
>> On Oct 24, 2017, at 2:27 AM, Jay McCarthy > > wrote: >> >> You do `raco pkg config --set git-checkout-credentials user:password` >> and then it will work. Sorry but I'm still stuck here. I did this: sudo raco pkg config --set git-checkout-credentials mbutteri

Re: [racket-users] `raco pkg install` from private GitHub repo?

2017-10-24 Thread Matthew Butterick
Thanks. Note to future mailing-list readers: this feature was introduced in Racket v6.7. > On Oct 24, 2017, at 2:27 AM, Jay McCarthy wrote: > > You do `raco pkg config --set git-checkout-credentials user:password` > and then it will work. -- You received this message because you are subscrib

[racket-users] `raco pkg install` from private GitHub repo?

2017-10-23 Thread Matthew Butterick
Seems like this has been asked before. But the exact search query is eluding me. One can do `raco pkg install http://url/to/public/git/repo`. Is it possible to use a private repo as the target of `raco pkg install`? (IIRC, no.) What is the least painful workaround? Make a local clone of the p

Re: [racket-users] code reflection

2017-10-19 Thread Matthew Butterick
> On Oct 19, 2017, at 9:09 AM, Konrad Hinsen wrote: > > These looks interesting, thanks! I'll have a closer look later. > I guess that some people would object to making all-upper-case a > semantic marker, but in terms of readability this looks nice. BTW I got some of those ideas from `sweet-m

Re: [racket-users] code reflection

2017-10-18 Thread Matthew Butterick
> On Oct 18, 2017, at 12:53 AM, Konrad Hinsen > wrote: > > I needed to remove the first > element and add it in front of the others. On a plain list, I could do > this half asleep. But with the list wrapped in a syntax object, even > after considerable thought I am not sure what the best approa

Re: [racket-users] Connecting a language and its reader

2017-10-03 Thread Matthew Butterick
> On Oct 1, 2017, at 12:50 PM, Jordan Johnson wrote: > > Correct me if I’m wrong in this understanding: the #'(module ...) is > effectively replacing the body of whatever program is written in #lang > mylang, so the path-string "semantics.rkt" must be interpreted relative to > that program’s

Re: [racket-users] Access pattern variable in macro

2017-10-03 Thread Matthew Butterick
> On Oct 3, 2017, at 10:31 AM, 'Shakin Billy' via Racket Users > wrote: > > how do i access the pattern variable var at compile time (phase 1?) > additional to an answer, could you point me to the right part of the > documentation? i really couldn't find it. `var` isn't a `procedure?` during

Re: [racket-users] using Racket web server behind Apache as proxied HTTPS app server

2017-09-26 Thread Matthew Butterick
> On Sep 26, 2017, at 5:13 PM, Alexis King wrote: > > In fact, to elaborate a little bit more: what you probably want to do > is only support HTTPS, but you will not want to only listen on port 443 ... > What you will want to do instead is automatically redirect any users who > use HTTP to the e

Re: [racket-users] using Racket web server behind Apache as proxied HTTPS app server

2017-09-26 Thread Matthew Butterick
> On Sep 26, 2017, at 3:45 PM, Alexis King wrote: > > When an HTTPS request reaches Apache, it will use the certificate > that it knows about to perform SSL negotiation, then it will forward the > decrypted HTTP request to your Racket server over ordinary HTTP. It will > subsequently encrypt the

[racket-users] using Racket web server behind Apache as proxied HTTPS app server

2017-09-26 Thread Matthew Butterick
The docs for "How do I use Apache with the Racket Web Server?" demonstrate how to set up proxying between Apache and the Racket web server within an .htaccess file. [1] That technique works. But only with ordinary HTTP. AFAICT it does not work for HTTPS. What's the best way to make this work

Re: [racket-users] "<>&" in script xexprs

2017-09-19 Thread Matthew Butterick
> On Sep 19, 2017, at 5:38 PM, Byron Davies wrote: > > Right. My understanding increases bit by bit. > > I’m using response/xexpr, which — unlike your xexpr->html — doesn’t > special-case script and style tags. Funny, I had read through your txexpr > docs, but the special-casing of script an

Re: [racket-users] "<>&" in script xexprs

2017-09-19 Thread Matthew Butterick
> On Sep 19, 2017, at 1:36 PM, Byron Davies wrote: > > In strings, xexpr->xml converts "<>&” into <, etc. I’m sure this was > well-intentioned, but in my use of web-server, I use javascript scripts > through the (script “…”) form. In loop tests such as “i < n”, Javascript > does not grok the

Re: [racket-users] Suppress print lines from required modules

2017-08-27 Thread Matthew Butterick
> On Aug 27, 2017, at 7:30 PM, Shu-Hung You > wrote: > > Something along the line of (open-output-file > "/dev/null") sounds a bit better but I'm not sure how to create a > discard-everything output port. `open-output-nowhere`? https://docs.racket-lang.org/reference/port-lib.html?q=open-outp

Re: [racket-users] Readers and Namespaces

2017-08-18 Thread Matthew Butterick
> On Aug 17, 2017, at 10:11 PM, Alexis King wrote: > > This is, for > better or for worse, currently a no-no in Racket — syntax objects > produced by a #lang’s reader are supposed to only have source locations > and syntax properties on them, not lexical context. Supposed to, yes. But AFAIK thi

Re: [racket-users] Can a macro "return" a macro without expanding it?

2017-08-18 Thread Matthew Butterick
> On Aug 18, 2017, at 2:28 AM, Sam Waxman wrote: > > If I have code like this, > > (define-syntax-rule (identity x) > x) > > ((identity identity) 1) > > Is there a simple way to change this so that ((identity identity) 1) actually > does expand into (identity 1) which expands into 1? I'm g

Re: [racket-users] Seeking expert opinion on how Racketeering tames web development chaos.

2017-07-31 Thread Matthew Butterick
> On Jul 30, 2017, at 8:02 PM, Sage Gerard wrote: > > Those of you working on the web know that Javascript went everywhere. Like a puppy never housebroken. > I see Racket can be used for web development, but is Racket really what I > need to meet the demands of multi-platform development whi

Re: [racket-users] IO in racket is painful

2017-07-22 Thread Matthew Butterick
> On Jul 22, 2017, at 12:30 PM, David Storrs wrote: > > One thing that would solve a lot of this issue would be if the pregexp syntax > added support for named captures as in Perl and the PCRE library that exports > them. > > Alternatively, if 'match' made the results of a successful regexp

Re: [racket-users] Replacing multiple characters in a string?

2017-07-08 Thread Matthew Butterick
> On Jul 8, 2017, at 7:15 AM, Robby Findler wrote: > > Below is another approach that may be too much Rackety for your taste: :) > > http://docs.racket-lang.org/lindenmayer/ Or, arguably, not Rackety enough, until it's possible to embed one #lang within another (submodules at least, but he

Re: [racket-users] Forwarding syntax or srcloc

2017-07-05 Thread Matthew Butterick
> On Jul 4, 2017, at 1:39 PM, reilithion wrote: > > I'd like to be able to get source location information from behind two or > more layers of macros. > > Unfortunately, the srcloc that gets stored ends up being the location of the > simplifying macro. Not what I want. I need to somehow forwa

Re: [racket-users] hacking falsiness

2017-07-01 Thread Matthew Butterick
> On Jul 1, 2017, at 3:43 PM, Matthew Flatt wrote: > > You're right that there's nothing like `#%boolean`. Beware that > adjusting all the `if`s in a fully expanded module won't help if the > expanded code call calls `filter`, `not`, or any other function from a > different module that expects a

Re: [racket-users] hacking falsiness

2017-07-01 Thread Matthew Butterick
> On Jul 1, 2017, at 2:24 PM, Deren Dohoda wrote: > > If your #lang has Greg's "if" then any module written in that #lang will use > that "if". IIUC Greg is suggesting something different than the usual shadow-and-export fandango that a module language ordinarily uses. He is suggesting tha

Re: [racket-users] hacking falsiness

2017-07-01 Thread Matthew Butterick
Good idea, but can I introduce a new macro (which naturally needs expansion) into a fully-expanded module (which does not)? IOW, it feels like you'd need to mangle #%kernel `if` before expansion, so that all the higher level expansions landed on the new mangled form. Mangling #%datum won't qui

[racket-users] hacking falsiness

2017-07-01 Thread Matthew Butterick
Suppose I'm making a DSL where #f, 0, and null all count as false values. What is the most efficient way to do this? IOW, is there a deep-and-simple way of globally affecting the Boolean tower (meaning, automatically changing all conditional forms)? Or does one have to build a new tower from th

Re: [racket-users] can `impersonate-hash` really filter out hash keys?

2017-06-30 Thread Matthew Butterick
That's a good suggestion. Yes, that will be smoother. > On Jun 30, 2017, at 10:31 AM, Philip McGrath wrote: > > If it doesn't absolutely have to be a hash, you can definitely make dict-ref > and dict-iterate-key etc. work differently. -- You received this message because you are subscribed t

Re: [racket-users] can `impersonate-hash` really filter out hash keys?

2017-06-30 Thread Matthew Butterick
> On Jun 30, 2017, at 10:07 AM, Robby Findler > wrote: > > Maybe you could make the impersonator (it would be a chaperone, really > in what I'm suggesting) signal an error if it gets one of the private > keys and then hand out only the hashes with the impersonator around > it, keeping the "raw"

Re: [racket-users] how to get full tracebacks in DrRacket?

2017-06-30 Thread Matthew Butterick
Whoa! Nice feature, perhaps a little too well camouflaged ;) > On Jun 30, 2017, at 8:41 AM, Robby Findler > wrote: > > You have to click on the icon (to the right of "in-list" in the example) to > see it in the current implementation. -- You received this message because you are subscribed

[racket-users] can `impersonate-hash` really filter out hash keys?

2017-06-30 Thread Matthew Butterick
I'd like to make a hash impersonator that has "private" keys that can be reached by `hash-ref`, but which are not reported by `hash-keys` and other operations that iterate over all keys. The docs for `impersonate-hash` [1] say that you can "use `key-proc` to filter keys extracted from the table

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

2017-06-27 Thread Matthew Butterick
> On Jun 27, 2017, at 6:31 PM, Glenn Hoetker > wrote: > > Naive question, here. As far as I can tell, (directory-list some-path) > yields a list of files and directories immediately below some-path. I wish to > capture all files and directories in some-path or any o

[racket-users] noob question: generic interfaces & classes

2017-06-25 Thread Matthew Butterick
How does one attach a generic interface to a class? `class*` allows one to attach an `interface` [2] (in the class sense of that term, which I understand is separate from that of "generic interface"). Then the docs for `interface*` show an example attaching the `prop:custom-write` property. [3

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

2017-06-13 Thread Matthew Butterick
> On Jun 13, 2017, at 6:34 AM, David Storrs wrote: > > There needs to be an easy and obvious way to edit the pages at > docs.racket-lang.org or an easy and obvious > way to go from the page to the relevant part of the GitHub repository This is a nice idea, thoug

[racket-users] (seventh RacketCon), Oct 7-8 @ Seattle: tickets, speakers, sponsors

2017-06-12 Thread Matthew Butterick
TICKETS Tickets are now available for (seventh RacketCon), which happens at the University of Washington in Seattle on Oct 7-8, a beautiful autumn weekend. Conference page: http://con.racket-lang.org/ Direct ticket link: https://www.eventbrite.com/e/racketcon-2017-

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

2017-05-19 Thread Matthew Butterick
> On May 19, 2017, at 7:52 AM, John Clements wrote: > > Sugar looks great; I just reimplemented your ‘filter-split’ for about the > seventeenth time yesterday while breaking a text file into paragraphs. For that, I prescribe `decode-paragraphs` http://docs.racket-lang.org/pollen/Decode.html

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

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

2017-05-02 Thread Matthew Butterick
> On May 2, 2017, at 4:33 PM, Daniel Prager wrote: > > (define/pre-post (real-sqrt x) > #:pre ([(real? x) "real argument expected"] > [(>= x 0) "non-negative argument expected"]) > > #:implementation (sqrt x) > > #:post ([(implies (= x 0) (= result 0)) "The sqrt of zero should b

[racket-users] Re: Any good way to shadow a required module?

2017-05-01 Thread Matthew Butterick
On Monday, May 1, 2017 at 9:55:10 PM UTC-7, Jinzhou Zhang wrote: > Thus my question is: is there any good way to shadow a required module? `subtract-in` http://docs.racket-lang.org/reference/require.html?q=subtract-in#%28form._%28%28lib._racket%2Frequire..rkt%29._subtract-in%29%29 -- You receiv

Re: [racket-users] student project idea: semi-WYSIWYG Scribble editor (Was: Racket 6.9)

2017-04-30 Thread Matthew Butterick
> On Apr 29, 2017, at 2:24 PM, Neil Van Dyke wrote: > > Alternatively, and simpler: you might have two window panes, one in which the > user writes Scribble source, and another that gives an almost-live > semi-WYSIWYG view of how the source would render. FWIW, Pollen includes dynamic preview

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

2017-04-25 Thread Matthew Butterick
> On Apr 25, 2017, at 4:05 PM, brendan wrote: > > Indeed; I should have clarified that I didn't mean only recursion per se. Not > the first time I've stumbled on that misnomer. > > On Tuesday, April 25, 2017 at 6:53:59 PM UTC-4, Robby Findler wrote: >> I think the question is about non-tail ca

Re: [racket-users] Any work on demo.racket-lang.org?

2017-04-25 Thread Matthew Butterick
> On Apr 25, 2017, at 3:14 AM, Tim Brown wrote: > > 1 Volume: there are 932 tasks implemented on Rosetta Code; all of > which have some value. Since I have contributed a fair number of > these, I know that there is a good amount of time required to just > review each of these pages. PS ab

Re: [racket-users] Any work on demo.racket-lang.org?

2017-04-24 Thread Matthew Butterick
> "Make a web page (demo.racket-lang ?) that contains Racket snippets. > > I'm looking to: > > b. make up some kind of curated wiki to host that code (and examples > from other sources) > c. make Racket look as capable of everything as we all know it is Instead of a wiki, perhaps consider col

Re: [racket-users] How to check if a value is not false

2017-04-15 Thread Matthew Butterick
> On Apr 15, 2017, at 7:16 AM, Angus wrote: > > I am doing it using cond like this: > > (define (lines t) > (cond [(and (false? (node-l t)) (false? (node-r t))) < thing>>] ;; if no children >[(and (false? (node-l t)) (not (node-r t))) <>] ;; > if left child only >[(and (nod

Re: [racket-users] string-split bug?

2017-04-07 Thread Matthew Butterick
You want (string-split ";;" ";" #:trim? #f) not (string-split ";;" ";" #:repeat? #t) On Fri, Apr 7, 2017 at 8:04 AM, Jean-François Trevien wrote: > Hello, > > When i enter the following command: > (string-split ";;" ";" #:repeat? #t) > I expect a list of 3 empty strings as answer but i obtain

Re: [racket-users] Reporting exceptions as though they came from the caller

2017-03-31 Thread Matthew Butterick
> On Mar 31, 2017, at 1:00 PM, David Storrs wrote: > > In Perl I can use caller() [1] to access the stack so that I can have _baz > report errors as though the error were coming from 'foo' or 'bar' as > appropriate -- which is what the user expects to see, since their code called > 'foo' or '

Re: [racket-users] how to `read-char` from port using `latin-1` encoding?

2017-03-31 Thread Matthew Butterick
OK thanks. Both "latin1" and "iso-8859-1" do work with `reencode-input-port`. > On Mar 31, 2017, at 1:08 PM, Jon Zeppieri wrote: > > Try using "iso-8859-1" as the name of the encoding, instead of "latin-1." -J > > > On Fri, Mar 3

[racket-users] how to `read-char` from port using `latin-1` encoding?

2017-03-31 Thread Matthew Butterick
IIUC when `read-char` reads from a port it assumes the port uses UTF-8 encoding. [1] (My Racketuition suggests there might be a parameter called `current-port-encoding` that controls what encoding is applied to the port, but apparently not.) So instead, one must convert the port explicitly. O

Re: [racket-users] How to use the REPL with #lang s-exp "expander.rkt"

2017-03-20 Thread Matthew Butterick
> On Mar 20, 2017, at 2:59 AM, Jan Hondebrink wrote: > > Testing top-interaction with expression: (#%top-interaction + 1 2) > . +: unbound identifier; > also, no #%app syntax transformer is bound in: + > > So when you pass an expression through to the racket/base #%module-begin, it > can use t

[racket-users] Beautiful Racket v1.0

2017-03-15 Thread Matthew Butterick
I'm very pleased to announce that Beautiful Racket, my book about making languages with Racket (that I spoke about at the last RacketCon) is now officially released: http://beautifulracket.com Special thanks to chief amigo Matthew Flatt for writing a very kind fore

Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-03 Thread Matthew Butterick
> On Mar 2, 2017, at 9:17 AM, David Storrs wrote: > > I could, it's just extremely more verbose and therefore obfuscates what's > actually going on as compared to the 'map' form. Why not turn it into a macro that preserves your preferred notation: #lang racket (struct foo (a b c) #:transpar

Re: [racket-users] syntax-local-lift-expression vs. syntax-local-lift-require

2017-02-27 Thread Matthew Butterick
> On Feb 27, 2017, at 4:51 PM, Jay McCarthy wrote: > > You don't want local-require? I don't think so — the `require` forms can be nested anywhere in the program. I want them to jump to the top level, and have their usual "global" effect. > On Feb 27, 2017, at 5:34 PM, gfb wrote: > > If y

[racket-users] syntax-local-lift-expression vs. syntax-local-lift-require

2017-02-27 Thread Matthew Butterick
Is there a simple way to lift a `require` form to the top level of a module? i.e., in the example below, is there something that would replace `WHAT-MAGIC-GOES-HERE?` to make it work? I understand that `syntax-local-lift-expression` won't work. But `syntax-local-lift-require`, as best I can di

Re: [racket-users] generate sentences

2017-02-25 Thread Matthew Butterick
> On Feb 25, 2017, at 1:33 PM, Linh Chi Nguyen > wrote: > > anyway, when being asked to say-something, the machine generates quite good > sentences. i have this secret hope [0] that if i feed it enough game theory > literature, somehow it can generate something of value for my phd thesis =))

Re: [racket-users] How do I find where a module is located?

2017-02-14 Thread Matthew Butterick
> On Feb 14, 2017, at 8:36 AM, David Storrs wrote: > > (find-system-path 'collects-dir) ;; yields ../collects, which is useless > /Applications/Racket_v6.6/collects ;; nothing > /Library/Application Support/ ;; no directory for Racket > ~/Library/Application Support/ ;; no directory for Racket

Re: [racket-users] Using brag parser library with Typed Racket

2017-02-04 Thread Matthew Butterick
> On Feb 4, 2017, at 8:18 AM, Sourav Datta wrote: > > (require/typed "grammar1.rkt" > [parse (->* (Listof Token) > (Any) > Syntax)]) > > Type Checker: Type (->* (Listof Token) (Any) Syntax) could not be converted > to a contract: r

Re: [racket-users] Package layout in docs

2017-01-30 Thread Matthew Butterick
> On Jan 30, 2017, at 11:42 AM, Leif Andersen wrote: > > I don't think that the solution is to make core packages first class, and > community ones second class. That looses the spirit of what we're going for > here. But maybe we could have in our documentation a way for users to select > wha

Re: [racket-users] New web page

2017-01-27 Thread Matthew Butterick
I always appreciate the feedback & suggestions. I will review these points carefully. Of course, one of the hard parts of a website redesign is that because preferences conflict, everyone ends up somewhat dissatisfied ;) But we will be continuing to revise the website, in terms of fixing bugs,

[racket-users] Re: MFlatt eval blog link broken in search engines

2017-01-22 Thread Matthew Butterick
While converting the blog I intended to preserve the Blogger.com permalink format so that new permalinks would remain the same as the old. (I'm guessing this one slipped through because Blogger did some kind of special truncation on this unusually long title.) The solution

Re: [racket-users] Creating and publishing modules

2017-01-20 Thread Matthew Butterick
> On Jan 20, 2017, at 12:56 PM, David Storrs wrote: > > Basics of packages: https://docs.racket-lang.org/pkg/Package_Concepts.html > Basics of modules: https://docs.racket-lang.org/guide/module-basics.html > Overall docs on packages (creating, using, publishing): > https://docs.racket-lang.org/p

[racket-users] Re: Custom define macro

2017-01-20 Thread Matthew Butterick
On Friday, January 20, 2017 at 1:49:12 PM UTC-8, Lehi Toskin wrote: > I have created a macro[1] that operates like regular define, but wraps the > definition around a struct with prop:procedure. This struct contains the > procedure to be used and a list representation of its definition. I've gott

Re: [racket-users] New website design feedback

2017-01-02 Thread Matthew Butterick
> On Jan 2, 2017, at 5:42 AM, Greg Trzeciak wrote: > > The reason I asked is because I've noticed some differences between images in > between version of the new website so I thought that maybe some generative > art package was used and I wondered what it could be. They're just little SVG doo

Re: [racket-users] Narrow radix of string->number.

2017-01-01 Thread Matthew Butterick
> On Dec 31, 2016, at 12:05 PM, Robby Findler > wrote: > > But this introduces an additional cost that's a little bit more > troublesome to measure. Specifically, each namespace that instantiates > `racket/base` will now take a tiny bit more space and take a tiny bit > longer to initialize. >

Re: [racket-users] Narrow radix of string->number.

2016-12-31 Thread Matthew Butterick
> On Dec 31, 2016, at 10:57 AM, Matthew Butterick wrote: > >> I started with Ryan's code from `~r` and tried to emulate some special >> cases I see the C code (and didn't worry about negative numbers) and >> ended up with something 4-5x slower than the C

Re: [racket-users] Narrow radix of string->number.

2016-12-31 Thread Matthew Butterick
> I started with Ryan's code from `~r` and tried to emulate some special > cases I see the C code (and didn't worry about negative numbers) and > ended up with something 4-5x slower than the C code version. :( Code > follows. Is it cheating to avoid divisions by using table lookups? cpu time:

Re: [racket-users] New website design feedback

2016-12-29 Thread Matthew Butterick
> On Dec 23, 2016, at 6:55 AM, Greg Trzeciak wrote: > > 1. There is one thing that frustrates me most when I stumble upon new > website/package/repository for the first time and I have no previous > knowledge of its content. It is due to the amount of time it takes me to get > an answer to a

Re: [racket-users] Fix Ctr+F search on the new website?

2016-12-29 Thread Matthew Butterick
> On Dec 28, 2016, at 6:18 AM, Leif Andersen wrote: > > I noticed that Ctr+F based searching is kind of uncomfortable on the new > website. Namely, if I am searching for a word that is located below one of > the images, it gets highlighted like you would expect, but the image doesn't > actual

Re: [racket-users] Mobile Friendly HTML in Scribble?

2016-12-28 Thread Matthew Butterick
> On Dec 28, 2016, at 6:06 AM, Michael Rossi wrote: > > couldn't you simply add all three code layout options and then add a > commandline switch in scribble when generating html? I.e. by default, do > nothing with the code. Otherwise, add switches to either wrap the code or > else put it in

Re: [racket-users] Narrow radix of string->number.

2016-12-27 Thread Matthew Butterick
> On Dec 27, 2016, at 1:57 PM, Robby Findler > wrote: > > The main thing I worry about is that there are standard conventions > that we're missing from other language families. Would someone mind > investigating a few other, popular languages FWIW Racket's own `~r` function already accepts rad

Re: [racket-users] Mobile Friendly HTML in Scribble?

2016-12-27 Thread Matthew Butterick
> On Dec 27, 2016, at 2:23 PM, Philip McGrath wrote: > However, when I just tried to simulate a smartphone viewport with the Chrome > developer tools, I got the "non-mobile friendly" behavior Michael described. > (I don't have my phone on me right now, so I haven't checked that.) I believe th

<    1   2   3   4   5   6   >