Re: [racket-users] cvs-reading ?

2016-10-29 Thread Meino . Cramer

Hi John,

thanks for your reply! :)

the only cause for makeing my life "terrible" at that moment
was myself and the lack of coffee
I confused csv with cvs
No need to apologize for anything, John!!!
I am the only person, who needs to apologize...you understand
everything correctly...

Only at work autocorrection is makeing my life terrible...in
that moments I want my Linux back... :)

Cheers
Meino



'John Clements' via Racket Users  [16-10-30 
07:08]:
> 
> > On Oct 29, 2016, at 22:35, meino.cra...@gmx.de wrote:
> > 
> > 
> > Hi John,
> > 
> > 
> > from my racket 6.6 installation ($HOME):
> > 
> > :user/.racket>l
> > total 20
> > drwxr-xr-x 5 user users 4096 2016-10-21 05:25 6.6
> > drwxr-xr-x 5 user users 4096 2016-10-30 06:21 6.7
> > drwxr-xr-x 2 user users 4096 2016-10-30 06:21 download-cache
> > -rw-r--r-- 1 user users 5254 2016-10-30 06:25 racket-prefs.rktd
> > :user/.racket>cd 6.6
> > :.racket/6.6>l
> > total 16
> > drwxr-xr-x 5 user users 4096 2016-10-21 05:26 doc
> > -rw-r--r-- 1 user users   91 2016-10-21 05:25 links.rktd
> > drwxr-xr-x 5 user users 4096 2016-10-21 05:25 pkgs
> > drwxr-xr-x 2 user users 4096 2016-10-21 05:25 share
> > :.racket/6.6>cd pkgs
> > :6.6/pkgs>l
> > total 16
> > drwxr-xr-x 4 user users 4096 2016-10-21 05:25 csv-reading
> > drwxr-xr-x 4 user users 4096 2016-10-21 05:25 mcfly
> > drwxr-xr-x 4 user users 4096 2016-10-21 05:25 overeasy
> > -rw-r--r-- 1 user users  373 2016-10-21 05:25 pkgs.rktd
> > :6.6/pkgs>
> > 
> > so I thought, that there must be a cvs-reading-pkg in 6.7
> > too…
> 
> hang on, look closely:
> 
> CSV-reading
> vs
> CVS-reading
> 
> not the same.
> 
> There is a csv-reading package. There is not a cvs-reading package.
> 
> Right?
> 
> Apologies if I’m misunderstanding you somehow. Or if auto-correct is making 
> your life terrible :).
> 
> John Clements
> 
> 
> -- 
> 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] cvs-reading ?

2016-10-29 Thread 'John Clements' via Racket Users

> On Oct 29, 2016, at 22:35, meino.cra...@gmx.de wrote:
> 
> 
> Hi John,
> 
> 
> from my racket 6.6 installation ($HOME):
> 
> :user/.racket>l
> total 20
> drwxr-xr-x 5 user users 4096 2016-10-21 05:25 6.6
> drwxr-xr-x 5 user users 4096 2016-10-30 06:21 6.7
> drwxr-xr-x 2 user users 4096 2016-10-30 06:21 download-cache
> -rw-r--r-- 1 user users 5254 2016-10-30 06:25 racket-prefs.rktd
> :user/.racket>cd 6.6
> :.racket/6.6>l
> total 16
> drwxr-xr-x 5 user users 4096 2016-10-21 05:26 doc
> -rw-r--r-- 1 user users   91 2016-10-21 05:25 links.rktd
> drwxr-xr-x 5 user users 4096 2016-10-21 05:25 pkgs
> drwxr-xr-x 2 user users 4096 2016-10-21 05:25 share
> :.racket/6.6>cd pkgs
> :6.6/pkgs>l
> total 16
> drwxr-xr-x 4 user users 4096 2016-10-21 05:25 csv-reading
> drwxr-xr-x 4 user users 4096 2016-10-21 05:25 mcfly
> drwxr-xr-x 4 user users 4096 2016-10-21 05:25 overeasy
> -rw-r--r-- 1 user users  373 2016-10-21 05:25 pkgs.rktd
> :6.6/pkgs>
> 
> so I thought, that there must be a cvs-reading-pkg in 6.7
> too…

hang on, look closely:

CSV-reading
vs
CVS-reading

not the same.

There is a csv-reading package. There is not a cvs-reading package.

Right?

Apologies if I’m misunderstanding you somehow. Or if auto-correct is making 
your life terrible :).

John Clements


-- 
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] ANN: profile-flame-graph package

2016-10-29 Thread Asumu Takikawa
Hi folks,

I recently wrote a Racket package that lets you visualize profiler outputs
using flame graphs[1]. The package handles the plumbing of hooking up the
profiler to Brendan Gregg's perl script[2] which does the actual visualization
work.

Anyhow, you can find it here with some instructions for use:

  https://github.com/takikawa/racket-profile-flamegraph

and on the pkg catalog as `profile-flame-graph`.

[1]: http://www.brendangregg.com/flamegraphs.html
[2]: https://github.com/brendangregg/FlameGraph

Cheers,
Asumu

-- 
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] cvs-reading ?

2016-10-29 Thread Meino . Cramer

Hi John,


from my racket 6.6 installation ($HOME):

:user/.racket>l
total 20
drwxr-xr-x 5 user users 4096 2016-10-21 05:25 6.6
drwxr-xr-x 5 user users 4096 2016-10-30 06:21 6.7
drwxr-xr-x 2 user users 4096 2016-10-30 06:21 download-cache
-rw-r--r-- 1 user users 5254 2016-10-30 06:25 racket-prefs.rktd
:user/.racket>cd 6.6
:.racket/6.6>l
total 16
drwxr-xr-x 5 user users 4096 2016-10-21 05:26 doc
-rw-r--r-- 1 user users   91 2016-10-21 05:25 links.rktd
drwxr-xr-x 5 user users 4096 2016-10-21 05:25 pkgs
drwxr-xr-x 2 user users 4096 2016-10-21 05:25 share
:.racket/6.6>cd pkgs 
:6.6/pkgs>l
total 16
drwxr-xr-x 4 user users 4096 2016-10-21 05:25 csv-reading
drwxr-xr-x 4 user users 4096 2016-10-21 05:25 mcfly
drwxr-xr-x 4 user users 4096 2016-10-21 05:25 overeasy
-rw-r--r-- 1 user users  373 2016-10-21 05:25 pkgs.rktd
:6.6/pkgs>

so I thought, that there must be a cvs-reading-pkg in 6.7
too...

?

Cheers
Meino

John Clements  [16-10-30 06:28]:
> 

> > On Oct 29, 2016, at 20:08, meino.cra...@gmx.de wrote:

> > 

> > Hi,

> > 

> > While using racket 6.6 I installed the package 'cvs-reading' in $HOME

> > with 'raco pkg install cvs-reading' as me (not as root).

> 

> Did you mean to write ‘csv-reading’ ? I don’t see a package named cvs-reading.

> 

> John Clements

> 

> > 

> > Now, after updateing to racket 6.7, this package cannot longer

> > be 'require'd :

> >> (require cvs-reading)

> > ; readline-input:1:9: collection not found

> > ;   for module path: cvs-reading

> > ;   collection: "cvs-reading"

> > ;   in collection directories:

> > ;/home/mccramer/.racket/6.7/collects

> > ;/usr/local/share/racket/collects

> > ;... [156 additional linked and package directories]

> > ; [,bt for context]

> > 

> > According to that output, all packages installed prior

> > to racket 6.7 are now no longer available since installed

> > under

> >/home/mccramer/.racket/6.7/collects

> > (that is: not version independantly).

> > 

> > Forthermore:

> > Repeating the above command

> >raco pkg install cvs-reading

> > 

> > fails with:

> >Resolving "cvs-reading" via 
> > https://download.racket-lang.org/releases/6.7/catalog/

> >Resolving "cvs-reading" via https://pkgs.racket-lang.org

> >Resolving "cvs-reading" via https://planet-compats.racket-lang.org

> >raco pkg install: cannot find package on catalogs

> >package: cvs-reading

> >[1]29873 exit 1 raco pkg install cvs-reading

> > 

> > 

> > Suppose I had installed 20 instead of only one package...

> > Do I need to reinstall all packages when upgrading racket (hopefully

> > not)...?

> > How can I reanimate my sources, which depends on 'cvs-reading'?

> > 

> > Cheers,

> > Meino

> > 

> > 

> > --

> > 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] Re: cvs-reading ?

2016-10-29 Thread Jack Firth
I'm not quite sure, but one thing I see off that I forgot to mention in my
previous post is that I think the package you want is "csv-reading", not
"cvs-reading".

On Sat, Oct 29, 2016 at 10:31 PM,  wrote:

>
> Hi Jack,
>
> thanks fpr your reply ! :)
>
> I tried that with this script (copied from the docs, "/bin/env racket
> replace by the actually path to racket):
>
> #!/usr/local/bin/racket; \
> #lang scripty  ; | script preamble
> #:dependencies '("cvs-reading"); /
> --
> #lang racket
>
> (require cvs-reading)
>
> and it failed with:
>
> default-load-handler: cannot open module file
> module path: #
> path: /home/mccramer/; \
> system error: No such file or directory; errno=2
> context...:
> standard-module-name-resolver
> [1]32658 exit 1 ./test.rkt
>
> What did I wrong here?
>
> Cheers
> Meino
>
> Jack Firth  [16-10-30 06:08]:
> > I would recommend adding `info.rkt` files to your projects so that your
> projects are *themselves* packages. In these info files you can declare
> what packages you depend on, so rather than manually installing
> dependencies one at a time globally (and reinstalling when upgrading
> racket), you simply install your project as a package and `raco pkg` will
> fetch all the dependencies you listed.
> >
> > If you're writing things that tend to be one-off scripts rather than
> full-blown projects and the overhead of an `info.rkt` file irks you, have a
> look at Scripty[1]. This is a Racket package that lets you write scripts
> that declare what packages they depend on in the script itself -- when you
> run the script, it prompts you to install any declared packages that aren't
> present. It's especially useful for replacing random shell scripts with
> racket scripts without forcing your coworkers to confront the racket
> packaging system.
> >
> > [1] http://docs.racket-lang.org/scripty/index.html
> >
> > --
> > 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] Re: cvs-reading ?

2016-10-29 Thread Meino . Cramer

Hi Jack,

thanks fpr your reply ! :)

I tried that with this script (copied from the docs, "/bin/env racket
replace by the actually path to racket):

#!/usr/local/bin/racket; \
#lang scripty  ; | script preamble
#:dependencies '("cvs-reading"); /
--
#lang racket

(require cvs-reading)

and it failed with:

default-load-handler: cannot open module file
module path: #
path: /home/mccramer/; \
system error: No such file or directory; errno=2
context...:
standard-module-name-resolver
[1]32658 exit 1 ./test.rkt

What did I wrong here?

Cheers
Meino

Jack Firth  [16-10-30 06:08]:
> I would recommend adding `info.rkt` files to your projects so that your 
> projects are *themselves* packages. In these info files you can declare what 
> packages you depend on, so rather than manually installing dependencies one 
> at a time globally (and reinstalling when upgrading racket), you simply 
> install your project as a package and `raco pkg` will fetch all the 
> dependencies you listed.
> 
> If you're writing things that tend to be one-off scripts rather than 
> full-blown projects and the overhead of an `info.rkt` file irks you, have a 
> look at Scripty[1]. This is a Racket package that lets you write scripts that 
> declare what packages they depend on in the script itself -- when you run the 
> script, it prompts you to install any declared packages that aren't present. 
> It's especially useful for replacing random shell scripts with racket scripts 
> without forcing your coworkers to confront the racket packaging system.
> 
> [1] http://docs.racket-lang.org/scripty/index.html
> 
> -- 
> 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] cvs-reading ?

2016-10-29 Thread 'John Clements' via Racket Users

> On Oct 29, 2016, at 20:08, meino.cra...@gmx.de wrote:
> 
> Hi,
> 
> While using racket 6.6 I installed the package 'cvs-reading' in $HOME
> with 'raco pkg install cvs-reading' as me (not as root).

Did you mean to write ‘csv-reading’ ? I don’t see a package named cvs-reading.

John Clements

> 
> Now, after updateing to racket 6.7, this package cannot longer
> be 'require'd :
>> (require cvs-reading)
> ; readline-input:1:9: collection not found
> ;   for module path: cvs-reading
> ;   collection: "cvs-reading"
> ;   in collection directories:
> ;/home/mccramer/.racket/6.7/collects
> ;/usr/local/share/racket/collects
> ;... [156 additional linked and package directories]
> ; [,bt for context]
> 
> According to that output, all packages installed prior
> to racket 6.7 are now no longer available since installed
> under
>/home/mccramer/.racket/6.7/collects
> (that is: not version independantly).
> 
> Forthermore:
> Repeating the above command
>raco pkg install cvs-reading
> 
> fails with:
>Resolving "cvs-reading" via 
> https://download.racket-lang.org/releases/6.7/catalog/
>Resolving "cvs-reading" via https://pkgs.racket-lang.org
>Resolving "cvs-reading" via https://planet-compats.racket-lang.org
>raco pkg install: cannot find package on catalogs
>package: cvs-reading
>[1]29873 exit 1 raco pkg install cvs-reading
> 
> 
> Suppose I had installed 20 instead of only one package...
> Do I need to reinstall all packages when upgrading racket (hopefully
> not)...?
> How can I reanimate my sources, which depends on 'cvs-reading'?
> 
> Cheers,
> Meino
> 
> 
> --
> 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.


signature.asc
Description: PGP signature


[racket-users] Re: cvs-reading ?

2016-10-29 Thread Jack Firth
I would recommend adding `info.rkt` files to your projects so that your 
projects are *themselves* packages. In these info files you can declare what 
packages you depend on, so rather than manually installing dependencies one at 
a time globally (and reinstalling when upgrading racket), you simply install 
your project as a package and `raco pkg` will fetch all the dependencies you 
listed.

If you're writing things that tend to be one-off scripts rather than full-blown 
projects and the overhead of an `info.rkt` file irks you, have a look at 
Scripty[1]. This is a Racket package that lets you write scripts that declare 
what packages they depend on in the script itself -- when you run the script, 
it prompts you to install any declared packages that aren't present. It's 
especially useful for replacing random shell scripts with racket scripts 
without forcing your coworkers to confront the racket packaging system.

[1] http://docs.racket-lang.org/scripty/index.html

-- 
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] Re: Convention for package build scripts (that don't really have to be part of the package)?

2016-10-29 Thread Jack Firth
I've thought about this as well, and I think a `-build` or a `-develop` package 
makes the most sense. As an aside, if you wanted to you could even add some 
Scribble docs to that package describing the implementation of your library and 
where important bits of it are. That kind of documentation is highly underrated 
in my view.

-- 
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] cvs-reading ?

2016-10-29 Thread Meino . Cramer
Hi,

While using racket 6.6 I installed the package 'cvs-reading' in $HOME
with 'raco pkg install cvs-reading' as me (not as root).

Now, after updateing to racket 6.7, this package cannot longer
be 'require'd :
> (require cvs-reading)
; readline-input:1:9: collection not found
;   for module path: cvs-reading
;   collection: "cvs-reading"
;   in collection directories:
;/home/mccramer/.racket/6.7/collects
;/usr/local/share/racket/collects
;... [156 additional linked and package directories]
; [,bt for context]

According to that output, all packages installed prior
to racket 6.7 are now no longer available since installed
under 
/home/mccramer/.racket/6.7/collects
(that is: not version independantly).

Forthermore:
Repeating the above command
raco pkg install cvs-reading

fails with:
Resolving "cvs-reading" via 
https://download.racket-lang.org/releases/6.7/catalog/
Resolving "cvs-reading" via https://pkgs.racket-lang.org
Resolving "cvs-reading" via https://planet-compats.racket-lang.org
raco pkg install: cannot find package on catalogs
package: cvs-reading
[1]29873 exit 1 raco pkg install cvs-reading


Suppose I had installed 20 instead of only one package...
Do I need to reinstall all packages when upgrading racket (hopefully
not)...?
How can I reanimate my sources, which depends on 'cvs-reading'?

Cheers,
Meino


-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Using the graph library

2016-10-29 Thread Daniel Prager
Starting at the very beginning, you could pick up some material on graph
theory, and work through it, while making use of the graph library.

E.g. Here's an introduction to the absolute basics of Graph Theory:

https://www.youtube.com/watch?v=HmQR8Xy9DeM


And here I've followed along in Racket, figuring out parts of the library
as I go:

#lang racket

(require graph
 math/matrix)

; Define a simple graph
(define g (unweighted-graph/undirected
   '((v1 v2) (v1 v3) (v1 v4) (v4 v5) (v5 v6


; How many vertices are in the graph?
(define (cardinality g)
  (length (get-vertices g)))

(cardinality g)


; How many neighbors does vertex v have?
(define (degree g v)
  (length (get-neighbors g v)))

(degree g 'v1)


; Compute the adjacency list
(define (adjacency-list g)
  (for/list ([v (in-vertices g)])
(list v
  (for/list ([ n (in-neighbors g v)])
n

(adjacency-list g)


; Compute the adjacency matrix
(define (adjacency-matrix g)
  (define card-g (cardinality g))
  (define vertices (for/list ([v (in-vertices g)]) v))
  (build-matrix card-g card-g
(λ (u v)
  (if (has-edge? g (list-ref vertices u) (list-ref vertices
v))
  1 0

(adjacency-matrix g)


; Is the graph actually a tree?
(define (is-tree? g)
  (= (length (get-edges g)); Counts edges twice (in both
directions)
 (* 2 (length (mst-kruskal g)

(is-tree? g)

(define loop (unweighted-graph/undirected '((a b) (a c) (b c
(is-tree? loop)


; Visualize the tree
(displayln (graphviz g))

; Paste output into www.webgraphviz.com to make an image


I hope that's enough to get you started

Dan

-- 
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] Request for comments: An embedded DSL for CSS in Racket

2016-10-29 Thread lfacchi2
> I'd be interested in trying a working prototype. It's hard to evaluate the 
> wisdom of the technical choices without enjoying the benefits of the new 
> interface.

Thank you for your interest. The implementation needs some fixes that I expect 
to finish by the end of the week that starts tomorrow. As soon as I do that, 
I’ll publish a preliminary version and let you know.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Using the graph library

2016-10-29 Thread Lawrence Bottorff
On Saturday, October 29, 2016 at 3:06:18 PM UTC-4, jhemann wrote:
> Stephen's talk at 4th Racketcon (https://www.youtube.com/watch?v=SvYJF5HC19w) 
> gave me a good tutorial-ish introduction. 
> 
> 
> JBH
> 
> 
> On Sat, Oct 29, 2016 at 8:59 PM, Lawrence Bottorff  wrote:
> I see the Racket Generic Graph Library, but I don't know how to use it. Where 
> would one go to learn, tutorial-style" the ins and outs of using this 
> library? I take it this library allows you to "roll your own" graph database? 
> I did notice the HTDP has a section on graph things. Would this help?
> 
> 
> 
> LB
> 
> 
> 
> --
> 
> 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...@googlegroups.com.
> 
> For more options, visit https://groups.google.com/d/optout.
> 
> 
> 
> 
> 
> -- 
> 
> 
> JBH

I would need something lots more basic-beginner than this talk. The Chang talk 
seems to assume a lot of graph knowledge. I'll pick through the Racket doc on 
the graph library, but it would be better for me to see something that starts 
at the very beginning.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Using the graph library

2016-10-29 Thread Jason Hemann
Stephen's talk at 4th Racketcon (https://www.youtube.com/watch?v=SvYJF5HC19w)
gave me a good tutorial-ish introduction.

JBH

On Sat, Oct 29, 2016 at 8:59 PM, Lawrence Bottorff 
wrote:

> I see the Racket Generic Graph Library, but I don't know how to use it.
> Where would one go to learn, tutorial-style" the ins and outs of using this
> library? I take it this library allows you to "roll your own" graph
> database? I did notice the HTDP has a section on graph things. Would this
> help?
>
> LB
>
> --
> 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.
>



-- 
JBH

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Using the graph library

2016-10-29 Thread Lawrence Bottorff
I see the Racket Generic Graph Library, but I don't know how to use it. Where 
would one go to learn, tutorial-style" the ins and outs of using this library? 
I take it this library allows you to "roll your own" graph database? I did 
notice the HTDP has a section on graph things. Would this help?

LB

-- 
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] Trying to build 'routing' macro for dispatch-rules

2016-10-29 Thread Jay McCarthy
Hi David,

The syntax of `dispatch-rules` is that its arguments are dispatch
clauses, not expressions, and it does not implement its own macro
system (like `match` does.)

You should either change `dispatch-rules` to do that by adding
"dispatch-rules-expanders" or make your own macro to expand into a
call to `dispatch-rules`

Jay

On Fri, Oct 28, 2016 at 2:49 PM, David Storrs  wrote:
> I'm trying to build a macro that will generate routing rules for
> 'dispatch-rules'.
>
> (dispatch-rules) from web-server/dispatch has this form:
>
> (dispatch-rules
>(("announce-user") #:method post process-announce-user))
>...more routes here...
> )
>
> This seems like it should be automatable, so I tried to write a macro
> to generate these rules.  I'd like
> (routing announce-user)
> to expand to the line above:(("announce-user") #:method post
> process-announce-user))
>
> Here's my stab at it, which is currently failing:
>
>
> ;;This part works if I use it directly, ie:
> ;;  [("announce-file") #:method post (make-route msg-announce-file
> announce-file*)]
> ;;
> (define (make-route msg-handler pbuf-type)
>   (lambda (req)
> (msg-handler (req->protobuf req pbuf-type
>
>
> ;;Let's try to generate the entire rule using the above
> (define-syntax (routing stx)
>   (syntax-case
>   stx ()
> ([_ pbuf-type]
>  (with-syntax* ([type-name(format-id stx "~a*" #'pbuf-type)]
> [handler-name (format-id stx "msg-~a" #'type-name)]
> [route-name   (symbol->string (syntax->datum
> (format-id stx "~a" (syntax->datum #'pbuf-type]
> )
>#'[(route-name) #:method "post" (make-route
> handler-name type-name)]
> ;;   #'(quote [(route-name) #:method "post"
> (make-route handler-name type-name)])
>
>
> ;;(routing announce-file)  ; If I use this (i.e. outside the
> dispatch-rules) in combination with the 'quote' version above, I see
> the correct thing
>
> (define-values (dispatch-request url-for)
>   (dispatch-rules
>(routing announce-file)
>[("create-user") #:method post process-create-user]
>...more routes here...
> )
>
> Error is:
>
> racket network/routing.rkt
> ~/app/network/routing.rkt:194.2: dispatch-rules: bad syntax
>   in: (dispatch-rules (routing announce-file) (("create-user")
> #:method post process-create-user) ...
>   context...:
>
> /Applications/Racket_v6.6/collects/syntax/parse/private/runtime-report.rkt:698:0:
> error/report
>
> /Applications/Racket_v6.6/collects/syntax/parse/private/runtime-report.rkt:28:0:
> call-current-failure-handler
>standard-module-name-resolver
>
>
> As mentioned in the comments, it does generate (the quoted form of)
> the correct thing if I:
>
> 1) inside the macro, comment in the 'quote' line and comment out the
> line above it
> 2) comment OUT the '(routing announce-file) that is inside dispatch-rules
> 3) comment IN the (routing announce-user) line that is just above 
> dispatch-rules
>
>
> My suspicion is that dispatch-rules is a macro and so my macro is not
> being expanded inside another macro.  That's not how I thought macros
> worked, though, so now I'm really puzzled.
>
> Can anyone clarify this for 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 https://groups.google.com/d/optout.



-- 
Jay McCarthy
Associate Professor
PLT @ CS @ UMass Lowell
http://jeapostrophe.github.io

   "Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
  - D&C 64:33

-- 
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] Putting Racket into the database or, more sanely, storing continuations

2016-10-29 Thread David Storrs
Actually, what I've ended up doing is this:

1) There's a globally accessible jumptable hash that any function is
free to register with.  The hash maps a string key to a procedure.

2) Tasks get stored to the 'tasks' table in the DB as a JSONB blob of
the form (e.g.):  { "function": "release-space"   "args-list": [
"/foo/bar" ] }, along with a timestamp, priority, and a "claimed"
field.

3) There's a worker pool of threads which periodically grab one entry
out of the table and execute it with (apply (jumptable "function")
(json-blob "args-list")).  (Note that I'm using rackjure, so the
'hash-ref' isn't necessary.) The example above it would reduce to
(apply release-space '("/foo/bar"))



It's a little down at the heels, and using a global variable is nasty,
but it works.  Tony's suggestion about MFA is cleaner but
dynamic-require is problematic when use raco exe to build an
executable (which I'll need to do).  Still, I'm glad to see that I
independently made it most of the way to a solution that a lot of
smart people regard as good.

Thanks all -- the input is much appreciated.

Dave

Thanks for the input everyone
On Sat, Oct 29, 2016 at 11:05 AM, Philip McGrath
 wrote:
> If you want to go this way (and I suspect that there may be a better way),
> rather than using eval, I would look at serial-lambda from
> web-server/lang/serial-lambda, which lets you create closures (like the
> values produced by lambda) that could be put into a TEXT field using
> serialize and write. The benefit is that once you read and deserialize, you
> have a value that can be directly applied to arguments or called as a thunk,
> not source code that needs to be evaluated.
>
> For one approach to security, see web-server/stuffers/hmac-sha1. There are
> probably additional considerations in your case, but it would at least
> ensure that your serialized closures in the database are not forged.
>
> But I wonder why you need to save these "tasks" to disk. Unless they need to
> persist across runs of the application, it seems like you might be better
> served using threads (and possibly custodians and/or will executors, which I
> haven't had much cause to play with yet). For example, to do something in 5
> minutes, you could write:
> (thread
>  (λ ()
>(sleep (* 60 5))
>;; do work
>))
> Then you could leave all the work of making sure your "tasks" actually run
> at the appropriate moment to Racket. (In fact, even if some of your tasks do
> need to persist across runs of your application, you could still use this
> approach for actually running them if you include a step in your startup
> sequence to re-spawn any tasks that remain in your database.)
>
> On Sat, Oct 29, 2016 at 6:27 AM Tony Garnock-Jones 
> wrote:
>>
>> On 10/28/2016 08:21 PM, David Storrs wrote:
>> > Is it possible to take (e.g.) a procedure object and decompose it back
>> > into its original source code?
>>
>> I don't believe this is possible without murky unsafe programming, but...
>>
>> > One (bad) idea that came to mind was to simply shove some Racket code
>> > into a TEXT field in the database, then eval it when the time comes.
>>
>> ... this isn't actually so bad. From what you write, I think you're
>> already seeing the potential pitfalls: what should be in scope of the
>> code to be eval'd?
>>
>> > Now, this is horrible for a lot of reasons (security and error
>> > handling being two of them)
>>
>> Security will be a problem no matter what, but I don't see that error
>> handling gives undue difficulty! What am I missing?
>>
>> > suppose I already had a function that did what I needed and I
>> > wanted to use that
>>
>> Instead of storing a list-representing-code-to-eval, you could store
>>
>>  - the name of a module
>>  - the name of a function
>>  - a list of argument values
>>
>> and use `dynamic-require` in your task runner to find the given function:
>>
>>   > (dynamic-require 'racket/list 'filter-map)
>>   #
>>
>> and then `apply` with the arguments...
>>
>> Erlang uses essentially this approach in many places where actually
>> passing a closure around would be problematic (e.g.: code upgrades;
>> serialization to databases; etc). Erlang terminology is to call the
>> triple of module name, function name, and arguments an "MFA".
>>
>> Cheers,
>>   Tony
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Good thing I caused an error today

2016-10-29 Thread 'John Clements' via Racket Users
Happy Birthday, Matthias!

-- 
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] How to 'apply' a function with optional parameters?

2016-10-29 Thread Meino . Cramer
Hi all,

...think, I have to apologize

I screwed it upit is a language (spoke one...not "programming" )
thing:
I read "List of strings" which in german is "Liste von Zeichenketten".
THIS expression means this:
"A" "B" "C"
(for example).
This applied to string-join in a germenglish head forms:
(string-join "A" "B" "C" "seperator")
But I had
(define lst (list "A" "B" "C"))
(string-join lst "seperator")

...so I thougt I need an "apply" to move the
string-join right in front of the "list of strings" (spoken language)
in the list of strings (racket-speak).

But despite of the nonsense I thought I now have learned
how to handle functions with additional arguments in case
of the need to 'apply' them. 
Thanks a lot Shu-Hung, for you help and the patience of all
who wanted de-confuse me ;)

(THANKS!)

Cheers,
Meino


Shu-Hung You  [16-10-29 18:08]:
> Hi Meino,
> 
> Could you give an example of lst or line? Unlike string-append, most of the 
> time
> string-join doesn't really require an 'apply'. As we can see:
> 
> > (string-append "a" "b" "c")
> "abc"
> > (string-join '("a" "b" "c") ":")
> "a:b:c"
> 
> While string-append takes all its arguments and concatenates them into a 
> string,
> string-join simply joins all the strings in its first argument (which
> should be a list of strings).
> So suppose we have 'line' to be a list of string, then string-append
> and string-join can
> be used as follows:
> 
> > (define line '("x" "y" "z"))
> > (apply string-append line)
> "xyz"
> > (string-join line " ")
> "x y z"
> 
> If string-join is really to be used with apply, then we need to first
> construct its arguments
> into a list. For instance, the first of example of string-join is turned into:
> 
> > (string-join '("a" "b" "c") ":")
> "a:b:c"
> > (apply string-join '(("a" "b" "c") ":"))
> "a:b:c"
> 
> Given 'line' to be a list of strings, we need to construct the
> separator as the second item in
> the argument list of string-join:
> 
> > (define line '("x" "y" "z"))
> > (apply string-join (list line " "))
> "x y z"
> 
> Best,
> Shu-Hung
> 
> On Sat, Oct 29, 2016 at 10:31 AM,   wrote:
> >
> > Hi Stephen,
> >
> > thanks for yoru reply ! ::)
> >
> > At the certain point of the program I get
> > a list as parameter 'lst', which contains
> > the sublists of strings. I wrote this
> > function:
> >
> >
> > (define (to-txt lst)
> >   (if (empty? lst)
> > lst
> > (let ((line (car lst)))
> >   (begin
> > (displayln (apply string-join line " " )) ;;; WRONG SYNTAX HERE
> > (to-txt (cdr lst))
> >
> > Since I get the sublists as parameters I need an 'apply' to 'inject'
> > (sorry...I am no native speaker...) 'string-join' into the list.
> >
> > But string-join has additional parameters, and I dont know how to
> > combine those with 'apply'?
> >
> > PS: The resulting strings will later be processed further... the
> > 'displayln' is just a placeholder...
> >
> > Cheers,
> > Meino
> >
> >
> > Stephen Chang  [16-10-29 17:16]:
> >> string-join already expects a list of strings, so are you sure you want 
> >> apply?
> >> Can you give a more specific example?
> >>
> >> Perhaps map or some other iteration is what you want?
> >>
> >> (for ([strs '(("a" "b") ("c" "D" "E"))])
> >>   (displayln (string-join strs " ")))
> >>
> >> =>
> >> a b
> >> c D E
> >>
> >> On Sat, Oct 29, 2016 at 10:27 AM,   wrote:
> >> > Hi,
> >> >
> >> > ...still improving my shortwave-broadcaster-dumper... :)
> >> >
> >> > I have a list with sublists of strings, which I want to concatenate.
> >> > Each sublist shall form one line of output.
> >> > I tried 'string-append', but this gives me something like this
> >> > (excerpt):
> >> > "189RikisutvarpidRas1+2-24001234567Icelandic"
> >> > ...the separating #\space is missing.
> >> >
> >> > The according code looks like this (excerpt)
> >> >
> >> > (apply string-append sublist)
> >> >
> >> > then I found 'string-join' which has extra-parameters
> >> > to define separator of all kinds.
> >> >
> >> > ...but...how can I express the 'apply'-instruction...with the
> >> > addional parameters???
> >> >
> >> > This looks something inbetween funny and weird:
> >> >
> >> > (apply string-join sublist " ")
> >> >
> >> > and racket mumbles:
> >> > apply: contract violation
> >> >   expected: list?
> >> >   given: " "
> >> >   argument position: 3rd
> >> >   other arguments...:
> >> >#
> >> >
> >> >
> >> > ?
> >> >
> >> > Cheers
> >> > Meino
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> > 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, se

Re: [racket-users] How to 'apply' a function with optional parameters?

2016-10-29 Thread Shu-Hung You
Hi Meino,

Could you give an example of lst or line? Unlike string-append, most of the time
string-join doesn't really require an 'apply'. As we can see:

> (string-append "a" "b" "c")
"abc"
> (string-join '("a" "b" "c") ":")
"a:b:c"

While string-append takes all its arguments and concatenates them into a string,
string-join simply joins all the strings in its first argument (which
should be a list of strings).
So suppose we have 'line' to be a list of string, then string-append
and string-join can
be used as follows:

> (define line '("x" "y" "z"))
> (apply string-append line)
"xyz"
> (string-join line " ")
"x y z"

If string-join is really to be used with apply, then we need to first
construct its arguments
into a list. For instance, the first of example of string-join is turned into:

> (string-join '("a" "b" "c") ":")
"a:b:c"
> (apply string-join '(("a" "b" "c") ":"))
"a:b:c"

Given 'line' to be a list of strings, we need to construct the
separator as the second item in
the argument list of string-join:

> (define line '("x" "y" "z"))
> (apply string-join (list line " "))
"x y z"

Best,
Shu-Hung

On Sat, Oct 29, 2016 at 10:31 AM,   wrote:
>
> Hi Stephen,
>
> thanks for yoru reply ! ::)
>
> At the certain point of the program I get
> a list as parameter 'lst', which contains
> the sublists of strings. I wrote this
> function:
>
>
> (define (to-txt lst)
>   (if (empty? lst)
> lst
> (let ((line (car lst)))
>   (begin
> (displayln (apply string-join line " " )) ;;; WRONG SYNTAX HERE
> (to-txt (cdr lst))
>
> Since I get the sublists as parameters I need an 'apply' to 'inject'
> (sorry...I am no native speaker...) 'string-join' into the list.
>
> But string-join has additional parameters, and I dont know how to
> combine those with 'apply'?
>
> PS: The resulting strings will later be processed further... the
> 'displayln' is just a placeholder...
>
> Cheers,
> Meino
>
>
> Stephen Chang  [16-10-29 17:16]:
>> string-join already expects a list of strings, so are you sure you want 
>> apply?
>> Can you give a more specific example?
>>
>> Perhaps map or some other iteration is what you want?
>>
>> (for ([strs '(("a" "b") ("c" "D" "E"))])
>>   (displayln (string-join strs " ")))
>>
>> =>
>> a b
>> c D E
>>
>> On Sat, Oct 29, 2016 at 10:27 AM,   wrote:
>> > Hi,
>> >
>> > ...still improving my shortwave-broadcaster-dumper... :)
>> >
>> > I have a list with sublists of strings, which I want to concatenate.
>> > Each sublist shall form one line of output.
>> > I tried 'string-append', but this gives me something like this
>> > (excerpt):
>> > "189RikisutvarpidRas1+2-24001234567Icelandic"
>> > ...the separating #\space is missing.
>> >
>> > The according code looks like this (excerpt)
>> >
>> > (apply string-append sublist)
>> >
>> > then I found 'string-join' which has extra-parameters
>> > to define separator of all kinds.
>> >
>> > ...but...how can I express the 'apply'-instruction...with the
>> > addional parameters???
>> >
>> > This looks something inbetween funny and weird:
>> >
>> > (apply string-join sublist " ")
>> >
>> > and racket mumbles:
>> > apply: contract violation
>> >   expected: list?
>> >   given: " "
>> >   argument position: 3rd
>> >   other arguments...:
>> >#
>> >
>> >
>> > ?
>> >
>> > Cheers
>> > Meino
>> >
>> >
>> >
>> >
>> >
>> > --
>> > 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.
>>
>
> --
> 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] How to 'apply' a function with optional parameters?

2016-10-29 Thread Pierpaolo Bernardi
On Sat, Oct 29, 2016 at 5:31 PM,   wrote:

> At the certain point of the program I get
> a list as parameter 'lst', which contains
> the sublists of strings. I wrote this
> function:
>
>
> (define (to-txt lst)
>   (if (empty? lst)
> lst
> (let ((line (car lst)))
>   (begin
> (displayln (apply string-join line " " )) ;;; WRONG SYNTAX HERE
> (to-txt (cdr lst))
>
> Since I get the sublists as parameters I need an 'apply' to 'inject'
> (sorry...I am no native speaker...) 'string-join' into the list.

You missed this hint from Stephen Chang: "string-join already expects
a list of strings, so are you sure you want apply?"

As is the case, this hint was spot on.  You don't need apply here,just
remove it and your function should work.

Also, the begin is not necessary (but it does no harm either).

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] How to 'apply' a function with optional parameters?

2016-10-29 Thread Meino . Cramer

Hi Stephen,

thanks for yoru reply ! ::)

At the certain point of the program I get
a list as parameter 'lst', which contains
the sublists of strings. I wrote this
function:


(define (to-txt lst)
  (if (empty? lst)
lst
(let ((line (car lst)))
  (begin
(displayln (apply string-join line " " )) ;;; WRONG SYNTAX HERE
(to-txt (cdr lst))

Since I get the sublists as parameters I need an 'apply' to 'inject'
(sorry...I am no native speaker...) 'string-join' into the list.

But string-join has additional parameters, and I dont know how to
combine those with 'apply'?

PS: The resulting strings will later be processed further... the
'displayln' is just a placeholder...

Cheers,
Meino


Stephen Chang  [16-10-29 17:16]:
> string-join already expects a list of strings, so are you sure you want apply?
> Can you give a more specific example?
> 
> Perhaps map or some other iteration is what you want?
> 
> (for ([strs '(("a" "b") ("c" "D" "E"))])
>   (displayln (string-join strs " ")))
> 
> =>
> a b
> c D E
> 
> On Sat, Oct 29, 2016 at 10:27 AM,   wrote:
> > Hi,
> >
> > ...still improving my shortwave-broadcaster-dumper... :)
> >
> > I have a list with sublists of strings, which I want to concatenate.
> > Each sublist shall form one line of output.
> > I tried 'string-append', but this gives me something like this
> > (excerpt):
> > "189RikisutvarpidRas1+2-24001234567Icelandic"
> > ...the separating #\space is missing.
> >
> > The according code looks like this (excerpt)
> >
> > (apply string-append sublist)
> >
> > then I found 'string-join' which has extra-parameters
> > to define separator of all kinds.
> >
> > ...but...how can I express the 'apply'-instruction...with the
> > addional parameters???
> >
> > This looks something inbetween funny and weird:
> >
> > (apply string-join sublist " ")
> >
> > and racket mumbles:
> > apply: contract violation
> >   expected: list?
> >   given: " "
> >   argument position: 3rd
> >   other arguments...:
> >#
> >
> >
> > ?
> >
> > Cheers
> > Meino
> >
> >
> >
> >
> >
> > --
> > 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.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] How to 'apply' a function with optional parameters?

2016-10-29 Thread Ken MacKenzie
Yeah that is much more concise than mine.  My newbie lack of knowledge on the 
stdlib is showing.

Ken

On Saturday, October 29, 2016 at 11:12:50 AM UTC-4, Stephen Chang wrote:
> string-join already expects a list of strings, so are you sure you want apply?
> Can you give a more specific example?
> 
> Perhaps map or some other iteration is what you want?
> 
> (for ([strs '(("a" "b") ("c" "D" "E"))])
>   (displayln (string-join strs " ")))
> 
> =>
> a b
> c D E
> 

-- 
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: How to 'apply' a function with optional parameters?

2016-10-29 Thread Meino . Cramer
Hi Ken,

thanks for your reply ! :)

The problem is much "simpler"... :)

You wrote the whole logic to dig into the strings in the sublists in
the big list.
That's already done and working

I am in search for doing this

(string-join '( "a" "b" "c") " " )  ;; ( "a" "b" "c") is the sublist

but in the context of apply:
(define (to-txt lst)
  (if (empty? lst)
lst
(let ((line (car lst)))
  (begin
(displayln (apply string-join line " ")) ;; THIS IS THE WRONG SYNTAX!!!
(to-txt (cdr lst))

...and printing the lines is only a intermediate resultthe joined
strings will be processed further in a later stage of this program.
That's why I need a complete string with separators.

Cheers
Meino





Ken MacKenzie  [16-10-29 16:48]:
> Not 100% sure of what you're asking so if I got this wrong pseudo code it for 
> me.  Remember I am kind of new to racket but I will give it a go:
> 
> As I understand it you have a list of lists of strings perhaps like this...
> 
> (('this' 'is' 'one')('this' 'is' 'another')('this' 'is' 'the' 'last'))
> 
> and you want to output as such
> 
> this is one
> this is another
> 
> this is the last
> 
> 
> Ok so here is how I would do this
> 
> I will write this as 2 functions, from your main code you call the first 
> passing it ...
> 
> big-list = the whole list of lists
> 
> ;;in main loop
> (per-line big-list)
> 
> (define (per-line blist)
>   (cond
> [(empty? blist) #f]
> [else
>   (per-item (first blist))
>   (newline)
>   (per-line (rest blist))]))
> 
> (define (per-item slist)
>   (cond
> [(empty? slist) #f]
> [else
>   (display (first slist))
>   (display " ")
>   (per-item (rest slist))]))
> 
> That should be about it.  Double check me an ide about matched parens and 
> brackets.  I just eyeballed this real quick in the message.  But that is the 
> approach I would take for a simple proof.
> 
> An alternate approach is per-item accepts a string argument and returns the 
> string to per-line to display.  But if the end goal is quick output this is a 
> bout as concise + readable as I think I can make it.
> 
> Ken
> 
> 
> On Saturday, October 29, 2016 at 10:27:09 AM UTC-4, meino.cramer wrote:
> > Hi,
> > 
> > ...still improving my shortwave-broadcaster-dumper... :)
> > 
> > I have a list with sublists of strings, which I want to concatenate.
> > Each sublist shall form one line of output.
> > I tried 'string-append', but this gives me something like this
> > (excerpt):
> > "189RikisutvarpidRas1+2-24001234567Icelandic"
> > ...the separating #\space is missing.
> > 
> > The according code looks like this (excerpt)
> > 
> > (apply string-append sublist)
> > 
> > then I found 'string-join' which has extra-parameters
> > to define separator of all kinds.
> > 
> > ...but...how can I express the 'apply'-instruction...with the 
> > addional parameters???
> > 
> > This looks something inbetween funny and weird:
> > 
> > (apply string-join sublist " ")
> > 
> > and racket mumbles:
> > apply: contract violation
> >   expected: list?
> >   given: " "
> >   argument position: 3rd
> >   other arguments...:
> >#
> > 
> > 
> > ?
> > 
> > Cheers
> > Meino
> 
> -- 
> 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] How to 'apply' a function with optional parameters?

2016-10-29 Thread Stephen Chang
string-join already expects a list of strings, so are you sure you want apply?
Can you give a more specific example?

Perhaps map or some other iteration is what you want?

(for ([strs '(("a" "b") ("c" "D" "E"))])
  (displayln (string-join strs " ")))

=>
a b
c D E

On Sat, Oct 29, 2016 at 10:27 AM,   wrote:
> Hi,
>
> ...still improving my shortwave-broadcaster-dumper... :)
>
> I have a list with sublists of strings, which I want to concatenate.
> Each sublist shall form one line of output.
> I tried 'string-append', but this gives me something like this
> (excerpt):
> "189RikisutvarpidRas1+2-24001234567Icelandic"
> ...the separating #\space is missing.
>
> The according code looks like this (excerpt)
>
> (apply string-append sublist)
>
> then I found 'string-join' which has extra-parameters
> to define separator of all kinds.
>
> ...but...how can I express the 'apply'-instruction...with the
> addional parameters???
>
> This looks something inbetween funny and weird:
>
> (apply string-join sublist " ")
>
> and racket mumbles:
> apply: contract violation
>   expected: list?
>   given: " "
>   argument position: 3rd
>   other arguments...:
>#
>
>
> ?
>
> Cheers
> Meino
>
>
>
>
>
> --
> 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] Putting Racket into the database or, more sanely, storing continuations

2016-10-29 Thread Philip McGrath
If you want to go this way (and I suspect that there may be a better way),
rather than using eval, I would look at serial-lambda from
web-server/lang/serial-lambda, which lets you create closures (like the
values produced by lambda) that could be put into a TEXT field using
serialize and write. The benefit is that once you read and deserialize, you
have a value that can be directly applied to arguments or called as a
thunk, not source code that needs to be evaluated.

For one approach to security, see web-server/stuffers/hmac-sha1
.
There are probably additional considerations in your case, but it would at
least ensure that your serialized closures in the database are not forged.

But I wonder why you need to save these "tasks" to disk. Unless they need
to persist across runs of the application, it seems like you might be
better served using threads (and possibly custodians
 and/or will
executors , which
I haven't had much cause to play with yet). For example, to do something in
5 minutes, you could write:
(thread
 (λ ()
   (sleep (* 60 5))
   ;; do work
   ))
Then you could leave all the work of making sure your "tasks" actually run
at the appropriate moment to Racket. (In fact, even if some of your tasks
do need to persist across runs of your application, you could still use
this approach for actually running them if you include a step in your
startup sequence to re-spawn any tasks that remain in your database.)

On Sat, Oct 29, 2016 at 6:27 AM Tony Garnock-Jones 
wrote:

> On 10/28/2016 08:21 PM, David Storrs wrote:
> > Is it possible to take (e.g.) a procedure object and decompose it back
> > into its original source code?
>
> I don't believe this is possible without murky unsafe programming, but...
>
> > One (bad) idea that came to mind was to simply shove some Racket code
> > into a TEXT field in the database, then eval it when the time comes.
>
> ... this isn't actually so bad. From what you write, I think you're
> already seeing the potential pitfalls: what should be in scope of the
> code to be eval'd?
>
> > Now, this is horrible for a lot of reasons (security and error
> > handling being two of them)
>
> Security will be a problem no matter what, but I don't see that error
> handling gives undue difficulty! What am I missing?
>
> > suppose I already had a function that did what I needed and I
> > wanted to use that
>
> Instead of storing a list-representing-code-to-eval, you could store
>
>  - the name of a module
>  - the name of a function
>  - a list of argument values
>
> and use `dynamic-require` in your task runner to find the given function:
>
>   > (dynamic-require 'racket/list 'filter-map)
>   #
>
> and then `apply` with the arguments...
>
> Erlang uses essentially this approach in many places where actually
> passing a closure around would be problematic (e.g.: code upgrades;
> serialization to databases; etc). Erlang terminology is to call the
> triple of module name, function name, and arguments an "MFA".
>
> Cheers,
>   Tony
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: How to 'apply' a function with optional parameters?

2016-10-29 Thread Ken MacKenzie
Not 100% sure of what you're asking so if I got this wrong pseudo code it for 
me.  Remember I am kind of new to racket but I will give it a go:

As I understand it you have a list of lists of strings perhaps like this...

(('this' 'is' 'one')('this' 'is' 'another')('this' 'is' 'the' 'last'))

and you want to output as such

this is one
this is another

this is the last


Ok so here is how I would do this

I will write this as 2 functions, from your main code you call the first 
passing it ...

big-list = the whole list of lists

;;in main loop
(per-line big-list)

(define (per-line blist)
  (cond
[(empty? blist) #f]
[else
  (per-item (first blist))
  (newline)
  (per-line (rest blist))]))

(define (per-item slist)
  (cond
[(empty? slist) #f]
[else
  (display (first slist))
  (display " ")
  (per-item (rest slist))]))

That should be about it.  Double check me an ide about matched parens and 
brackets.  I just eyeballed this real quick in the message.  But that is the 
approach I would take for a simple proof.

An alternate approach is per-item accepts a string argument and returns the 
string to per-line to display.  But if the end goal is quick output this is a 
bout as concise + readable as I think I can make it.

Ken


On Saturday, October 29, 2016 at 10:27:09 AM UTC-4, meino.cramer wrote:
> Hi,
> 
> ...still improving my shortwave-broadcaster-dumper... :)
> 
> I have a list with sublists of strings, which I want to concatenate.
> Each sublist shall form one line of output.
> I tried 'string-append', but this gives me something like this
> (excerpt):
> "189RikisutvarpidRas1+2-24001234567Icelandic"
> ...the separating #\space is missing.
> 
> The according code looks like this (excerpt)
> 
> (apply string-append sublist)
> 
> then I found 'string-join' which has extra-parameters
> to define separator of all kinds.
> 
> ...but...how can I express the 'apply'-instruction...with the 
> addional parameters???
> 
> This looks something inbetween funny and weird:
> 
> (apply string-join sublist " ")
> 
> and racket mumbles:
> apply: contract violation
>   expected: list?
>   given: " "
>   argument position: 3rd
>   other arguments...:
>#
> 
> 
> ?
> 
> Cheers
> Meino

-- 
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] Request for comments: An embedded DSL for CSS in Racket

2016-10-29 Thread Matthew Butterick

On Oct 28, 2016, at 8:58 AM, lfacc...@jhu.edu wrote:

> Regarding the syntax of the DSL, I was intentionally vague about it in the
> original post because I wanted to focus on the technical choices I made.

I'd be interested in trying a working prototype. It's hard to evaluate the 
wisdom of the technical choices without enjoying the benefits of the new 
interface.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] How to 'apply' a function with optional parameters?

2016-10-29 Thread Meino . Cramer
Hi,

...still improving my shortwave-broadcaster-dumper... :)

I have a list with sublists of strings, which I want to concatenate.
Each sublist shall form one line of output.
I tried 'string-append', but this gives me something like this
(excerpt):
"189RikisutvarpidRas1+2-24001234567Icelandic"
...the separating #\space is missing.

The according code looks like this (excerpt)

(apply string-append sublist)

then I found 'string-join' which has extra-parameters
to define separator of all kinds.

...but...how can I express the 'apply'-instruction...with the 
addional parameters???

This looks something inbetween funny and weird:

(apply string-join sublist " ")

and racket mumbles:
apply: contract violation
  expected: list?
  given: " "
  argument position: 3rd
  other arguments...:
   #


?

Cheers
Meino





-- 
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] Re: Print...a newbies problem ;)

2016-10-29 Thread Ken MacKenzie
As a curiosity what happens when you run it as such

racket shwrefmt.rkt > debug.log

Ken

-- 
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] Print...a newbies problem ;)

2016-10-29 Thread Meino . Cramer
Hi,

currently I am still doing old-school "printf()-debugging", knowing
that it's '(print arg)' rather than 'printf( fmt, val,...);". :)

Since my program reads a bigger textfile of shortwave broadcasters,
their frequencies, on-air times, etc, reformats the whole thing
and (currently only to proof, everything is correct) prints it.

Since I need to now, where strings are starting and ending, I am using
'print' for that rather than 'pretty-print' or 'display'.

I am doing all this on UNIX/Linux.

To give myself a chance of reading the output I do this

racket shwrefmt.rkt | vim -

which reads everything, which goes to stdout into vim.

As long as I am using 'display', everything is fine.
When using 'print' the output mutates to smoke and vanishes in the pipe -
Vim starts with nothing to show.
'print'ing to the console works fine, though.

Giving at the REPL
> (current-output-port)
it says
#

which looks like the good-old STDOUT of UNIX to me...

Where is the output gone? <>

Thanks a lot for any help in advance!
Cheers,
Meino





-- 
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] Putting Racket into the database or, more sanely, storing continuations

2016-10-29 Thread Tony Garnock-Jones
On 10/28/2016 08:21 PM, David Storrs wrote:
> Is it possible to take (e.g.) a procedure object and decompose it back
> into its original source code?

I don't believe this is possible without murky unsafe programming, but...

> One (bad) idea that came to mind was to simply shove some Racket code
> into a TEXT field in the database, then eval it when the time comes.

... this isn't actually so bad. From what you write, I think you're
already seeing the potential pitfalls: what should be in scope of the
code to be eval'd?

> Now, this is horrible for a lot of reasons (security and error
> handling being two of them)

Security will be a problem no matter what, but I don't see that error
handling gives undue difficulty! What am I missing?

> suppose I already had a function that did what I needed and I
> wanted to use that

Instead of storing a list-representing-code-to-eval, you could store

 - the name of a module
 - the name of a function
 - a list of argument values

and use `dynamic-require` in your task runner to find the given function:

  > (dynamic-require 'racket/list 'filter-map)
  #

and then `apply` with the arguments...

Erlang uses essentially this approach in many places where actually
passing a closure around would be problematic (e.g.: code upgrades;
serialization to databases; etc). Erlang terminology is to call the
triple of module name, function name, and arguments an "MFA".

Cheers,
  Tony

-- 
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] 6.7.0.2: DYLD, [0x1] Library missing (macOS 10.12)

2016-10-29 Thread ylluminate
Anyone see this on the snapshot builds yet when you try to execute DrRacket?

Process:   DrRacket [47564]
Path:  /Volumes/VOLUME/*/DrRacket.app/Contents/MacOS/DrRacket
Identifier:org.racket-lang.DrRacket
Version:   6.7.0.2 (6.7.0.2)
Code Type: X86-64 (Native)
Parent Process:??? [1]
Responsible:   DrRacket [47564]
User ID:   501

Date/Time: 2016-10-29 03:45:47.090 -0400
OS Version:Mac OS X 10.12 (16A323)
Report Version:12
Anonymous UUID:C922F17F-2738-E434-EFFD-92FD7558E87E


Time Awake Since Boot: 38 seconds

System Integrity Protection: disabled

Crashed Thread:0

Exception Type:EXC_CRASH (SIGABRT)
Exception Codes:   0x, 0x
Exception Note:EXC_CORPSE_NOTIFY

Termination Reason:DYLD, [0x1] Library missing

Application Specific Information:
dyld: launch, loading dependent libraries

Dyld Error Message:
  Library not loaded: 
@executable_path/../../../lib/Racket.framework/Versions/6.7.0.2_3m/Racket
  Referenced from: /Volumes/VOLUME/*/DrRacket.app/Contents/MacOS/DrRacket
  Reason: image not found

Binary Images:
   0x10af3b000 -0x10af43ff7 +org.racket-lang.DrRacket (6.7.0.2 - 
6.7.0.2) <89A5AB8A-5352-3D66-94F2-A5A902B0137F> 
/var/folders/*/DrRacket.app/Contents/MacOS/DrRacket
   0x10e96c000 -0x10e9a91c7  dyld (421.1) 
 /usr/lib/dyld

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