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 all files: `(in-glob (build-path some-path "**"))`

On Tue, Jun 27, 2017 at 10:17 PM, Glenn Hoetker  wrote:

> Struggling as a newbie with the documentation for find-files. In
> particular, the "predicate" part of
>
> (find-files
> predicate
>  [  start-path]
> #:skip-filtered-directory? skip-filtered-directory?
> #:follow-links? follow-links?)
>
> Can anyone offer a working example?  All file, all pdfs. Doesn't really
> matter. Just something concrete to get me started. Many thanks!
>
> --
> 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] Built-in way to list all children of a directory?

2017-06-27 Thread Glenn Hoetker
Struggling as a newbie with the documentation for find-files. In particular, 
the "predicate" part of 

(find-files  
predicate
 [  start-path]  
#:skip-filtered-directory? skip-filtered-directory?  
#:follow-links? follow-links?)

Can anyone offer a working example?  All file, all pdfs. Doesn't really matter. 
Just something concrete to get me started. Many thanks!

-- 
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] Built-in way to list all children of a directory?

2017-06-27 Thread Matthew Flatt
At Tue, 27 Jun 2017 18:31:21 -0700 (PDT), Glenn Hoetker wrote:
> 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 of the sub-directories
> of some-path.

I would use `in-directory` with one of the `for` forms, but see also
`find-files` and `fold-files`.

-- 
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] 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 of the sub-directories 
> of some-path.  

`in-directory`, which is designed to be used within a `for` loop:

http://docs.racket-lang.org/reference/sequences.html?q=in-directory#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._in-directory%29%29
 


Use with `for/list` if you want to gather the results into a list.

Use `#:when` to restrict the results.

-- 
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] Built-in way to list all children of a directory?

2017-06-27 Thread Glenn Hoetker
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 of the sub-directories of 
some-path.  I didn't find an obvious option for doing so. Before I write my 
own--probably inefficient--way of doing so, I wanted to ask if there was a 
built-in command that would yield all the children of a path.  Many thanks.

-- 
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] Redex: difficulty with #refers-to

2017-06-27 Thread 'William J. Bowman' via Racket Users
On Tue, Jun 27, 2017 at 07:21:48PM -0500, Robby Findler wrote:
> On Tue, Jun 27, 2017 at 3:23 PM, 'William J. Bowman' via Racket Users
>  wrote:
> > (Unfortunately, there is a known bug in Redex that #...bind is 
> > undocumented, so you had no way to know about this)
> 
> I agree that #:...bind is complex and the documentation is not ideal,
> but I believe you helped me improve it, so I'm not that known bug is
> really the most helpful reply here. Perhaps a pointer to the docs is
> better. Here it is:
> 
> https://plt.eecs.northwestern.edu/snapshots/current/doc/redex/The_Redex_Reference.html#%28form._%28%28lib._redex%2Freduction-semantics..rkt%29._define-language%29%29
Oh I didn't realize that documentation was live already. Should the bug be 
closed?
(this should probably go off-list)

--
William J. Bowman

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


signature.asc
Description: PGP signature


Re: [racket-users] Redex: difficulty with #refers-to

2017-06-27 Thread Robby Findler
On Tue, Jun 27, 2017 at 3:23 PM, 'William J. Bowman' via Racket Users
 wrote:
> (Unfortunately, there is a known bug in Redex that #...bind is undocumented, 
> so you had no way to know about this)

I agree that #:...bind is complex and the documentation is not ideal,
but I believe you helped me improve it, so I'm not that known bug is
really the most helpful reply here. Perhaps a pointer to the docs is
better. Here it is:

https://plt.eecs.northwestern.edu/snapshots/current/doc/redex/The_Redex_Reference.html#%28form._%28%28lib._redex%2Freduction-semantics..rkt%29._define-language%29%29

Meanwhile, Justin, I wasn't able to make your example work exactly the
way you had it, but with an extra pair of parens around the `d`s thing
seem fine.

#lang racket
(require redex/reduction-semantics)

(define-language L
  (p ::= (prog (d ...) e))
  (d ::= (defun (x x) e))
  (e ::= x (e e) (+ e e) natural)
  (x ::= variable-not-otherwise-mentioned)
  #:binding-forms
  (defun (x_fun x_param) e #:refers-to x_param) #:exports x_fun
  (prog (d ...) #:refers-to (shadow d ...)
e_main #:refers-to (shadow d ...)))

(term (substitute (prog ((defun (f x) (g x))
 (defun (g x) (f (+ x y
(+ (f 1) (g 2)))
  f
  1)
  #:lang L)

hth,
Robby

-- 
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] Redex: difficulty with #refers-to

2017-06-27 Thread Justin Pombrio
On Tuesday, June 27, 2017 at 4:23:35 PM UTC-4, William J. Bowman wrote:
> On Tue, Jun 27, 2017 at 09:21:59AM -0700, Justin Pombrio wrote:
> > I'm trying to define a language in Redex that includes a list of top-level 
> > function definitions:
> > 
> >   (p ::= 
> > (prog (defun (x x) e) ... e))
> > 
> > And all function names should be in scope in all function bodies (other 
> > things should be in scope as well, but I'm ignoring them here for 
> > simplicity):
> > 
> >   (prog (defun (x_fun x_param) e_body #:refers-to (shadow x_fun ...)) ...
> > e_main))
> This looks ill-formed to me. Inside e_body, there is only one x_fun bound, so 
> x_fun ... doesn't make
> sense.
> This would make sense if you had a multi-argument functions, e.g.,
>(prog (defun (x_fun x ...) e_body #:refers-to (shadow x ...)) ...
>  e_main))
> 
> You're trying to express a more complicated binding pattern than merely a 
> list of binders.
> This is expressing that each definition d inside (prog d ...) exports a name 
> that is bound for all other definitions.
> You need #:exports.
> Maybe something like
>(defun (x_fun x ...) e_body #:refers-to (shadow x ...)) #:exports x_fun
>(prog d #:...bind (defs d (shadows defs d
> 
> This may not be quite right yet.
> 
> (Unfortunately, there is a known bug in Redex that #...bind is undocumented, 
> so you had no way to know about this)
> 
> --
> William J. Bowman

Ah, thanks Will.

-- 
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] Re: DrRacket becomes unresponsive when confronted with a long line

2017-06-27 Thread Robby Findler
I think that this is boiling down to an issue in the design of the
internal datastructures of the editor. Specifically, they use a linear
data structure to record each line and so very very long lines like
that are going to cause performance problems, generally speaking.
Below is an example program that is performing essentially the same
computation that typing a close paren at the end of that line performs
(not exactly hte same, but morally the same). Run it via the
command-line, e.g. `racket tmp.rkt` (if tmp.rkt contains the content
of that file).

You might try turning on word wrapping. That will make things
complete, but maybe not super quickly. Probably best to generate files
(assuming this one is a generated file?) with shorter lines. Removing
the semi-colon in the code below shows how that affects the
computation (for me, it goes from forever to maybe 14 seconds).

hth,
Robby

#lang racket/gui
(require framework)

(define f (new frame% [label ""] [width 500] [height 500]))
(define t (new text%))
(define ec (new editor-canvas% [parent f] [editor t]))
(send f reflow-container)
;(send t auto-wrap #t)

(send t load-file "drracket-problem-plain.rkt")
(define s1 (make-object style-delta% 'change-bold))
(define s2 (make-object style-delta% 'change-italic))
(time
 (let loop ([i 0]
[s1 s1]
[s2 s2])
   (when (zero? (modulo i 200))
 (printf "~a\n" (current-process-milliseconds)))
   (when (< i (send t last-position))
 (send t change-style s1 i (+ i 1))
 (loop (+ i 1) s2 s1




On Mon, Jun 26, 2017 at 10:28 PM, Philip McGrath
 wrote:
> I spoke too soon about continuing to edit as normal: actually, I can paste
> text and use backspace after the long line, but attempting to type anything
> further on in the file renders DrRacket unresponsive. Sometimes, when I
> "Force Quit" DrRacket (Mac OS), a DrRacket error window flickers onto the
> screen, but it's gone before I can read it.
>
> file->value for me, for now.
>
> -Philip
>
> On Mon, Jun 26, 2017 at 10:22 PM, Philip McGrath 
> wrote:
>>
>> When I open the attached file (which contains a very long line) in
>> DrRacket and attempt to type a closing parenthesis (either ")" or "]") on
>> line 4 (i.e. to close the define form), DrRacket becomes unresponsive until
>> forcibly killed (at least for several minutes, and even the caret stops
>> blinking). Interestingly, if I paste a closing parenthesis at that position,
>> I can continue editing as normal.
>>
>> I don't know if this is relevant, but when I attached
>> drracket-problem-file.rkt, I noticed it somehow wound up in the WXME format:
>> drracket-problem-plain.rkt is a plain-text version and appears to exhibit
>> the same issue.
>>
>> Thanks,
>> Philip
>
>
> --
> 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] Redex: difficulty with #refers-to

2017-06-27 Thread 'William J. Bowman' via Racket Users
On Tue, Jun 27, 2017 at 09:21:59AM -0700, Justin Pombrio wrote:
> I'm trying to define a language in Redex that includes a list of top-level 
> function definitions:
> 
>   (p ::= 
> (prog (defun (x x) e) ... e))
> 
> And all function names should be in scope in all function bodies (other 
> things should be in scope as well, but I'm ignoring them here for simplicity):
> 
>   (prog (defun (x_fun x_param) e_body #:refers-to (shadow x_fun ...)) ...
> e_main))
This looks ill-formed to me. Inside e_body, there is only one x_fun bound, so 
x_fun ... doesn't make
sense.
This would make sense if you had a multi-argument functions, e.g.,
   (prog (defun (x_fun x ...) e_body #:refers-to (shadow x ...)) ...
 e_main))

You're trying to express a more complicated binding pattern than merely a list 
of binders.
This is expressing that each definition d inside (prog d ...) exports a name 
that is bound for all other definitions.
You need #:exports.
Maybe something like
   (defun (x_fun x ...) e_body #:refers-to (shadow x ...)) #:exports x_fun
   (prog d #:...bind (defs d (shadows defs d

This may not be quite right yet.

(Unfortunately, there is a known bug in Redex that #...bind is undocumented, so 
you had no way to know about this)

--
William J. Bowman

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


signature.asc
Description: PGP signature


[racket-users] Redex: difficulty with #refers-to

2017-06-27 Thread Justin Pombrio
I'm trying to define a language in Redex that includes a list of top-level 
function definitions:

  (p ::= 
(prog (defun (x x) e) ... e))

And all function names should be in scope in all function bodies (other things 
should be in scope as well, but I'm ignoring them here for simplicity):

  (prog (defun (x_fun x_param) e_body #:refers-to (shadow x_fun ...)) ...
e_main))

However, this produces an internal error in Redex:

../../../../../usr/share/racket/pkgs/redex-lib/redex/private/reduction-semantics.rkt:2710:7:
 second: contract violation
  expected: list?
  given: 'f«0»

Any advice?

-- 
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] DrRacket Font Selection

2017-06-27 Thread Robby Findler
So I guess this is a bug somewhere in how event handling is happening.
If you wanted to work around it temporarily so you can set the font
how you want to, you could change this `unless` expression to be just
its body, ie `(force-cache receiver)`.

https://github.com/racket/drracket/blob/master/drracket/drracket/private/font.rkt#L88-L91

At least, I think that will work. Alternatively, you could add:

```
(thread (lambda () (sleep .1) (queue-callback (force-cache font-name-control
```

just after this line:

https://github.com/racket/drracket/blob/master/drracket/drracket/private/font.rkt#L96

and hopefully that'll work.

Robby


On Mon, Jun 26, 2017 at 6:55 PM, Lehi Toskin  wrote:
> Yes, that is correct.
>
> --
> 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] Change how to print builtins

2017-06-27 Thread Matthew Flatt
Besides struct-specific printing, the pretty printer from
`racket/pretty` provides a hook for changing the printed form of
anything via `pretty-print-size-hook` plus `pretty-print-print-hook`.

At Thu, 22 Jun 2017 18:39:15 -0700 (PDT), Sam Waxman wrote:
> Hello,
> 
> I was having trouble figuring out how to get racket to print values however I 
> wanted. In particular, I was hoping to make exact nums print as decimals and 
> true print as true (and not #t or #true). It would also be nice if I could 
> custom print procedures so that + printed as plain old + or in some other 
> yet-to-be-decided format. There might be other minor cosmetic things I'd like 
> to do in the future, so if there's a general way to write my own printer, 
> that 
> would be preferred, but if there are builtin features just to do the first 
> two 
> specific things, that would be pretty helpful too.
> 
> (I have to imagine there are pretty good ways to do this considering 
> user-defined #langs could print out all sorts of things, and they're not just 
> wrapping all their values in structs with custom print settings are they?)
> 
> Many thanks in advance
> 
> -- 
> 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] R7RS implementation's installation

2017-06-27 Thread Gustavo Massaccesi
(Just guessing) Do you have a proxy in the university? Can you install
other packages that are not part of the main distribution, for example
https://pkgs.racket-lang.org/package/cond-strict ?

Gustavo

On Thu, Jun 22, 2017 at 6:44 PM, Jean-Michel HUFFLEN
 wrote:
>Dear Racket developers,
>
>On my personal computer, I successfully installed the package for the
> nonofficial implementation of R7RS in Racket.
>
>But I didn't this operation at my university, the answer is
>
> https://... proxy web incorrect address
>
>I searched the documentation but I don't see how I could fix this
> problem? Can someone help me? Many thanks in advance,
>
> J.-M. Hufflen
>
>
> 
> This message was sent using IMP, the Internet Messaging Program.
>
> --
> 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.