[racket-users] demande d'aide

2016-10-13 Thread Masto Fine
 je commence en drracket et je cherche qqun qui pourrait m'aaider pour l 
construction de petits programmes ! 
 j'en suis par exemple a la construction de petits mondes , et je ne comprends 
pas comment programmer la differences entre une evolution spatiales (avec 
l'axes des abscisses , ordonnees ) comme dans l'exemple de mon manuel ; et une 
evolution numerique " en valeur absolue" comme dans l'exercice que je dois 
realiser : construite une horloge numerique. 
  l variable mathematiue ne me pose pas de problemes , c'est juste au moment de 
programmer l'evolution numerique dans l discretisation du monde , ou la 
programmation monde -monde ou celle monde-image que je peche . 
  Pouvez vous m'aider.

-- 
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] Unable to track down what is requiring inclusion of tzinfo module - Resolved

2016-10-13 Thread Sam Tobin-Hochstadt
That's likely the problem. Usually you need to use define-runtime-path or a
variant of that to cooperate with raco exe.

Sam

On Thu, Oct 13, 2016, 11:48 PM Jon Zeppieri  wrote:

> I'm sure someone else knows better than I do, but I guess the problem is
> that this technique (using `resolve-module-path` and `dynamic-require`)
> won't work with `raco exe`. Is that right? Or is something else going on?
>
> - Jon
>
>
> On Thu, Oct 13, 2016 at 8:55 PM, Ian Thomas  wrote:
>
> On Thursday, October 13, 2016 at 6:18:56 PM UTC-4, Ian Thomas wrote:
> >
> > I installed "gregor" using the following raco command.
> >
> >   raco pkg install gregor
> >
> > My Racket installation looks in the following directories for
> Collections:
> >
> > racket@setup/dirs> (get-collects-search-dirs)
> > '(#
> >   #
> >   #)
> >
> > Contents of "Users/ian/Library/Racket/6.6/collects", which includes
> tzinfo and the rest of Gregor's dependencies.
> >
> > $ ls ~/Library/Racket/6.6/pkgs/
> > cldr-bcp47cldr-dates-modern   cldr-numbers-modern
>  gregor-doc  memoize tzinfo
> > cldr-core cldr-localenames-modern gregor
> gregor-lib  pkgs.rktd
> >
> > I built my executable using the following raco command.
> >
> >   raco exe -o date_analyzer driver.rkt
> >
> > The executable works without issue if I don't require
> "../lib/date_analysis.rkt", which requires "gregor", but then, of course,
> I'm not able to do any date analysis.
> >
> > This one's a real mystery. Any further suggestions welcome.
>
> The issues appears to be with the tzinfo package itself that attempts to
> require submodule zoneinfo-data, but there is no zoneinfo-data submodule in
> tzinfo, nor is there currently a tzinfo/zoneinfo-data package period.
>
> $ grep zoneinfo-data -r *
> Binary file tzinfo/tzinfo/compiled/main_rkt.zo matches
> tzinfo/tzinfo/main.rkt:;; Load the zoneinfo-data package, if it's installed
> tzinfo/tzinfo/main.rkt:  (and (file-exists? (resolve-module-path
> 'tzinfo/zoneinfo-data #f))
> tzinfo/tzinfo/main.rkt:   (dynamic-require 'tzinfo/zoneinfo-data
> 'ZONEINFO-DATA)))
>
> $ find tzinfo/ -iname 'zoneinfo-data*'
> $
>
> Maybe tzinfo worked with a previous version of OS X: I'm running Sierra.
>
> $ uname -rsv
> Darwin 16.0.0 Darwin Kernel Version 16.0.0: Mon Aug 29 17:56:20 PDT 2016;
> root:xnu-3789.1.32~3/RELEASE_X86_64
>
> I resolved the issue by commenting out the following lines in
> tzinfo/tzinfo/main.rkt:
>
> ;;(define ZONEINFO-DATA
> ;;  (and (file-exists? (resolve-module-path 'tzinfo/zoneinfo-data #f))
> ;;   (dynamic-require 'tzinfo/zoneinfo-data 'ZONEINFO-DATA)))
>
> re-running raco setup, and finally recompiled my executable.
>
> --
> 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] Unable to track down what is requiring inclusion of tzinfo module - Resolved

2016-10-13 Thread Jon Zeppieri
I'm sure someone else knows better than I do, but I guess the problem is
that this technique (using `resolve-module-path` and `dynamic-require`)
won't work with `raco exe`. Is that right? Or is something else going on?

- Jon


On Thu, Oct 13, 2016 at 8:55 PM, Ian Thomas  wrote:

> On Thursday, October 13, 2016 at 6:18:56 PM UTC-4, Ian Thomas wrote:
> >
> > I installed "gregor" using the following raco command.
> >
> >   raco pkg install gregor
> >
> > My Racket installation looks in the following directories for
> Collections:
> >
> > racket@setup/dirs> (get-collects-search-dirs)
> > '(#
> >   #
> >   #)
> >
> > Contents of "Users/ian/Library/Racket/6.6/collects", which includes
> tzinfo and the rest of Gregor's dependencies.
> >
> > $ ls ~/Library/Racket/6.6/pkgs/
> > cldr-bcp47cldr-dates-modern   cldr-numbers-modern
>  gregor-doc  memoize tzinfo
> > cldr-core cldr-localenames-modern gregor
> gregor-lib  pkgs.rktd
> >
> > I built my executable using the following raco command.
> >
> >   raco exe -o date_analyzer driver.rkt
> >
> > The executable works without issue if I don't require
> "../lib/date_analysis.rkt", which requires "gregor", but then, of course,
> I'm not able to do any date analysis.
> >
> > This one's a real mystery. Any further suggestions welcome.
>
> The issues appears to be with the tzinfo package itself that attempts to
> require submodule zoneinfo-data, but there is no zoneinfo-data submodule in
> tzinfo, nor is there currently a tzinfo/zoneinfo-data package period.
>
> $ grep zoneinfo-data -r *
> Binary file tzinfo/tzinfo/compiled/main_rkt.zo matches
> tzinfo/tzinfo/main.rkt:;; Load the zoneinfo-data package, if it's installed
> tzinfo/tzinfo/main.rkt:  (and (file-exists? (resolve-module-path
> 'tzinfo/zoneinfo-data #f))
> tzinfo/tzinfo/main.rkt:   (dynamic-require 'tzinfo/zoneinfo-data
> 'ZONEINFO-DATA)))
>
> $ find tzinfo/ -iname 'zoneinfo-data*'
> $
>
> Maybe tzinfo worked with a previous version of OS X: I'm running Sierra.
>
> $ uname -rsv
> Darwin 16.0.0 Darwin Kernel Version 16.0.0: Mon Aug 29 17:56:20 PDT 2016;
> root:xnu-3789.1.32~3/RELEASE_X86_64
>
> I resolved the issue by commenting out the following lines in
> tzinfo/tzinfo/main.rkt:
>
> ;;(define ZONEINFO-DATA
> ;;  (and (file-exists? (resolve-module-path 'tzinfo/zoneinfo-data #f))
> ;;   (dynamic-require 'tzinfo/zoneinfo-data 'ZONEINFO-DATA)))
>
> re-running raco setup, and finally recompiled my executable.
>
> --
> 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] Scribble: Advice for treating content as structured data foremost and as documents secondarily?

2016-10-13 Thread CJ Gaconnet
On Wednesday, October 12, 2016 at 7:03:47 PM UTC-5, Matthew Butterick wrote:
> On Oct 12, 2016, at 4:19 PM, CJ Gaconnet wrote:
> > 
> > To recap, I'm looking to treat my written output as structured 
> > datums/syntax objects/structs foremost, which I can 
> > traverse/combine/transform into documents as needed; I want to extend my 
> > ontology of datums easily whenever needed; I want to define translations of 
> > new datums into various content-types whenever relevant.
> 
> Scribble is two separate components: the @-expression syntax, and the 
> document model / rendering system.
> 
> If you want to use both, try the full `scribble` dialects, like 
> `scribble/doc`.
> 
> If you only want @-expressions, try the `at-exp` metalanguage, which you can 
> mix in to any Racket language.
> 
> 
> > Finally, something like `(math-term "finite list")`, when embedded into a 
> > document, should be able to render to html as ' > class="math-term">finite list' and to TeX as "\textbf{finite list}", 
> > and I should be able to define new entity types & their content-type 
> > translations easily whenever needed.
> 
> 
> You can do that with Pollen, which I derived from Scribble. 
> 
> http://docs.racket-lang.org/pollen/

Thank you for the advice, Matthew. Pollen looks quite relevant to my needs 
(that's a great name by the way—evocative!). I will spend time reading through 
its docs and source code. So far, Section 6.2 "Optional reading: the case 
against Markdown" practically read my mind. I also ran across your book 
Beautiful Racket which looks equally relevant for me. I'm sure both of these 
resources will be very useful as I try to build something that works for me, so 
thank you.

-- 
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] OSX 10.12

2016-10-13 Thread JCG
"You have OS X 10.11.6. The application requires OS X 10.12 or later."

That's the error my 64bit Mac sees running 6.7.0.1 Dr. Racket from the normal 
.app icon.  However, running the executables directly, e.g. 
the-directory/bin/drracket works.

I don't know if the app launch requirement for 10.12 is intentional or not - 
I'm guessing not.

On a happy side note - it's faster than my 6.6 install, both in measurement and 
in feel.

-- 
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] Unable to track down what is requiring inclusion of tzinfo module - Resolved

2016-10-13 Thread Ian Thomas
On Thursday, October 13, 2016 at 6:18:56 PM UTC-4, Ian Thomas wrote:
> 
> I installed "gregor" using the following raco command.
> 
>   raco pkg install gregor
> 
> My Racket installation looks in the following directories for Collections:
> 
> racket@setup/dirs> (get-collects-search-dirs)
> '(#
>   #
>   #)
> 
> Contents of "Users/ian/Library/Racket/6.6/collects", which includes tzinfo 
> and the rest of Gregor's dependencies.
> 
> $ ls ~/Library/Racket/6.6/pkgs/
> cldr-bcp47cldr-dates-modern   cldr-numbers-modern 
> gregor-doc  memoize tzinfo
> cldr-core cldr-localenames-modern gregor  
> gregor-lib  pkgs.rktd
> 
> I built my executable using the following raco command. 
> 
>   raco exe -o date_analyzer driver.rkt
> 
> The executable works without issue if I don't require 
> "../lib/date_analysis.rkt", which requires "gregor", but then, of course, I'm 
> not able to do any date analysis.
> 
> This one's a real mystery. Any further suggestions welcome.

The issues appears to be with the tzinfo package itself that attempts to 
require submodule zoneinfo-data, but there is no zoneinfo-data submodule in 
tzinfo, nor is there currently a tzinfo/zoneinfo-data package period.

$ grep zoneinfo-data -r *
Binary file tzinfo/tzinfo/compiled/main_rkt.zo matches
tzinfo/tzinfo/main.rkt:;; Load the zoneinfo-data package, if it's installed
tzinfo/tzinfo/main.rkt:  (and (file-exists? (resolve-module-path 
'tzinfo/zoneinfo-data #f))
tzinfo/tzinfo/main.rkt:   (dynamic-require 'tzinfo/zoneinfo-data 
'ZONEINFO-DATA)))

$ find tzinfo/ -iname 'zoneinfo-data*'
$ 

Maybe tzinfo worked with a previous version of OS X: I'm running Sierra.

$ uname -rsv
Darwin 16.0.0 Darwin Kernel Version 16.0.0: Mon Aug 29 17:56:20 PDT 2016; 
root:xnu-3789.1.32~3/RELEASE_X86_64

I resolved the issue by commenting out the following lines in 
tzinfo/tzinfo/main.rkt:

;;(define ZONEINFO-DATA
;;  (and (file-exists? (resolve-module-path 'tzinfo/zoneinfo-data #f))
;;   (dynamic-require 'tzinfo/zoneinfo-data 'ZONEINFO-DATA)))

re-running raco setup, and finally recompiled my executable.

-- 
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 edit the htdp package from a release?

2016-10-13 Thread Alex Harsanyi
On Thursday, October 13, 2016 at 12:01:44 AM UTC+8, Matthew Flatt wrote:
> 
> In this case, things will work better if you use
> 
>  $ bin/raco pkg update --catalog https://pkgs.racket-lang.org htdp

I tried to run this command (as I also would like to work on some built in 
packages), and after it run successfully, my racket installation seems broken.  
Running raco without any arguments gives out warnings:

warning: tool "contract-profile" registered twice: "contract-profile" and 
#
warning: tool "dependencies-graph" registered twice: "dependencies-graph" and 
#
warning: tool "docs" registered twice: "docs" and #
warning: tool "check-requires" registered twice: "check-requires" and 
#
warning: tool "show-dependencies" registered twice: "show-dependencies" and 
#
warning: tool "macro-profiler" registered twice: "macro-profiler" and 
#
warning: tool "planet" registered twice: "planet" and #
warning: tool "profile" registered twice: "profile" and #
warning: tool "scribble" registered twice: "scribble" and #

and trying to run DrRacket also fails with errors about duplicate languages.

I'm using Racket 6.6 (released version), no extra packages installed on a 
Windows 7 64 bit OS.

What am I doing wrong?

Thanks,
Alex.

-- 
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] Unable to track down what is requiring inclusion of tzinfo module

2016-10-13 Thread Ian Thomas
On Thursday, October 13, 2016 at 2:05:53 PM UTC-4, Vincent St-Amour wrote:
> The tzinfo dependency comes from gregor (well, from gregor-lib, which
> gregor depends on).
> 
> But, I would have also expected installing gregor to pull in that
> dependency. How did you install gregor?
> 
> Vincent

I installed "gregor" using the following raco command.

  raco pkg install gregor

My Racket installation looks in the following directories for Collections:

racket@setup/dirs> (get-collects-search-dirs)
'(#
  #
  #)

Contents of "Users/ian/Library/Racket/6.6/collects", which includes tzinfo and 
the rest of Gregor's dependencies.

$ ls ~/Library/Racket/6.6/pkgs/
cldr-bcp47  cldr-dates-modern   cldr-numbers-modern 
gregor-doc  memoize tzinfo
cldr-core   cldr-localenames-modern gregor  
gregor-lib  pkgs.rktd

I built my executable using the following raco command. 

  raco exe -o date_analyzer driver.rkt

The executable works without issue if I don't require 
"../lib/date_analysis.rkt", which requires "gregor", but then, of course, I'm 
not able to do any date analysis.

This one's a real mystery. Any further suggestions welcome.

-- 
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 'repeated' with the murphy/protobuf module

2016-10-13 Thread David Storrs
Is anyone familiar with the murphy/protobuf module?  I'm running into two
issues:
1) How do I use non-primitive types?
2) How do I use 'repeated' fields?

I'm working with the Protocol Buffers standard, using the murphy/protobuf

module from PLaneT.  This works:


;;   In file defs.rkt
#lang racket/base
(require (planet murphy/protobuf:1/syntax))

(define-message-type
  endpoint
  ((required primitive:string address 1)
   (required primitive:int32 id 2)))

(provide (all-defined-out))



;;   In file serialize.rkt
#lang racket

(require (planet murphy/protobuf))
(require "defs.rkt")

(define p (endpoint* #:address "129.127.8.8" #:id 42))

(serialize p) ;; serialize, send to the current output port



;;  in file deserialize.rkt
#lang racket

(require (planet murphy/protobuf))
(require "defs.rkt")

(endpoint-address (deserialize (endpoint*)))  ;; read from current input
port




;;At command line:
$ racket serialize.rkt | racket deserialize.rkt
"129.127.8.8"



What I'd like to be able to do is create and then use something like this:

(define-message-type
endpoint_list
((repeated endpoint the_points 1)))

Whenever I try this, however, I get strange error message that mean nothing
to me, such as:

   'match-lambda: no matching clause for #'
and 'deserialize: missing required fields: (seteqv 1 2)'

I've tried digging through the source of the protobuf module, but it's
making my brain hurt.  Any advice would be gratefully received.

Dave

-- 
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 insert @ character into scribble-generated output?

2016-10-13 Thread Vincent St-Amour
FWIW, that's confused me too in the past, so I've added this as an extra
example in the docs.

Vincent


On Thu, 13 Oct 2016 08:42:13 -0500,
Robby Findler wrote:
> 
> You can do @"@" (i.e. escape to Racket with the first @ and then make
> a string that has an @ in it as the result of the escape).
> 
> Or you can change the @ character to another one, perhaps using pollen
> (it uses a diamond lozenge thingy).
> 
> Robby
> 
> 
> On Thu, Oct 13, 2016 at 8:20 AM, Kathi Fisler  wrote:
> > I need to put a sample of a JUnit test case in a sribble document, along 
> > the lines of
> >
> >  @verbatim{
> >@Test
> >public void checkHBLen() {
> >   assertEquals(HapBD.lenInSeconds, 25);
> > }
> >   }
> >
> > What's the escape sequence for treating the @ on Test literally, rather 
> > than as a scribble command.  Couldn't find this in the reader documentation.
> >
> > 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.

-- 
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] Unable to track down what is requiring inclusion of tzinfo module

2016-10-13 Thread Vincent St-Amour
The tzinfo dependency comes from gregor (well, from gregor-lib, which
gregor depends on).

But, I would have also expected installing gregor to pull in that
dependency. How did you install gregor?

Vincent



On Thu, 13 Oct 2016 13:02:09 -0500,
Ian Thomas wrote:
> 
> Hello list,
> 
> I'm receiving the following error when trying to run my application:
> 
> ./date_analyzer --help
> 
> standard-module-name-resolver: collection not found
>   for module path: tzinfo/zoneinfo-data
>   collection: "tzinfo"
>   in collection directories:
>   context...:
>show-collection-err
>standard-module-name-resolver
>/Applications/Racket v6.6/collects/syntax/modresolve.rkt:58:0: 
> resolve-module-path11
>/Applications/Racket 
> v6.6/collects/racket/contract/private/arrow-val-first.rkt:306:25
>#%embedded:g2357:main: [running body]
>#%embedded:g2314:main: [traversing imports]
>#%embedded:g2249:date_analysis: [traversing imports]
>#%mzc:driver: [traversing imports]
>loop
> 
> My application is made up of the following 5 files, with the requirements 
> listed after each, and none of the files contain functions from the tzinfo 
> package. 
> 
> bin/driver.rkt
> #lang racket
> (require racket/base
>racket/cmdline
>  "../lib/date_analysis.rkt")
> 
> lib/date_analysis.rkt
> #lang racket
> (require gregor
>"series.rkt")
> 
> lib/ipt_file.rkt
> #lang racket
> 
> lib/series.rkt
> #lang racket
> 
> test/test.rkt
> #lang racket
> (require "series.rkt")
> 
> Additional suggestions on other things to try to track down the source of 
> this bug are welcome.
> 
> 
> -- 
> 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] Unable to track down what is requiring inclusion of tzinfo module

2016-10-13 Thread Ian Thomas
Hello list,

I'm receiving the following error when trying to run my application:

./date_analyzer --help

standard-module-name-resolver: collection not found
  for module path: tzinfo/zoneinfo-data
  collection: "tzinfo"
  in collection directories:
  context...:
   show-collection-err
   standard-module-name-resolver
   /Applications/Racket v6.6/collects/syntax/modresolve.rkt:58:0: 
resolve-module-path11
   /Applications/Racket 
v6.6/collects/racket/contract/private/arrow-val-first.rkt:306:25
   #%embedded:g2357:main: [running body]
   #%embedded:g2314:main: [traversing imports]
   #%embedded:g2249:date_analysis: [traversing imports]
   #%mzc:driver: [traversing imports]
   loop

My application is made up of the following 5 files, with the requirements 
listed after each, and none of the files contain functions from the tzinfo 
package. 

bin/driver.rkt
#lang racket
(require racket/base
 racket/cmdline
 "../lib/date_analysis.rkt")

lib/date_analysis.rkt
#lang racket
(require gregor
 "series.rkt")

lib/ipt_file.rkt
#lang racket

lib/series.rkt
#lang racket

test/test.rkt
#lang racket
(require "series.rkt")

Additional suggestions on other things to try to track down the source of this 
bug are welcome.


-- 
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] Unable to utilize parse-command-line to build command line application

2016-10-13 Thread Ian Thomas
On Wednesday, October 12, 2016 at 3:15:11 PM UTC-4, Ian Thomas wrote:
> On Wednesday, October 12, 2016 at 10:19:28 AM UTC-4, Ben Greenman wrote:
> > Alright, here's something that I think does what you want.
> > 
> > 
> > 
> > #lang racket
> > 
> > 
> > (require racket/base
> >  racket/cmdline)
> > 
> > 
> > (parse-command-line "com_line"
> >  ;; argv
> >  (current-command-line-arguments)
> >  ;; table
> >  `((once-each
> >          [("-i" "--input-file")
> >          ,(lambda (flag) (displayln "Using "))
> >          ("Use input file as the input file.")]))
> >  ;; finish-proc
> >  (lambda (flag-accum file) file)
> >  ;; arg-help-strs
> >  '("Input file.")
> >  ;; help-proc
> >  (lambda (flag) (raise-user-error "com_line -i | --input-file input file")))
> > 
> > 
> > ;; $ ./com_line --input-file "hacking.rkt"
> > ;; Using 
> > ;; "hacking.rkt"
> > 
> > 
> > ;; $ ./com_line --help
> > ;; com_line -i | --input-file input file
> > 
> > 
> > 
> > The code in your last message expects 1 flag, 1 argument to the flag  
> > (`in`), and 1 `file` argument.
> 
> Okay - I've figured this out. Output from testing below. I'll add in exit 
> codes for the help-proc and unknown-proc so the finish-proc is never executed 
> in cases where the user asks for help or uses an unknown flag. I'd rather 
> return exit codes instead of raising an error as this code will likely be 
> interacting with other code via a shell. Thanks for the exception handling 
> suggestion.



I now believe I have a handle on how parse-command-line works. Working code 
that does what I want is below. Marking this post complete. 

Thanks

#lang racket

(require racket/base
 racket/cmdline)

(require "../lib/date_analysis.rkt")

(define usage "date_analyzer [-l --enable-logging] ")

  
(parse-command-line "date_analyzer"
;; argv 

   
(current-command-line-arguments)
;; table

   
`((once-each
   [("-l" "--enable-logging")
,(lambda (flag)
   (displayln "Enable logging of errors to a log 
file."))
("Enable logging to a log file.")]))
;; finish-proc  

   
(lambda (flag-accum input_file)
  (displayln (string-append "Run analysis on the data in "
input_file))
  (exit 0))
;; arg-help-strs

   
'("Input File")
;; help-proc

   
(lambda (flag)
  (displayln usage)
  (exit 1))
;; unknown-proc 

   
(lambda (unknown_flag)
  (displayln (string-append "Unknown flag: " unknown_flag))
  (displayln usage)
  (exit 1)))

-- 
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] Iterate over a list to construct a single string?

2016-10-13 Thread Gregor Kopp
Am Donnerstag, 13. Oktober 2016 17:19:51 UTC+2 schrieb David K. Storrs:
> David Christiansen's answer was very detailed and thorough, but I wanted to 
> add one more.  If I understand it, your goal is to take an arbitrary 
> (possibly nested) list of strings and concatenate all the strings.  This will 
> do that: ...

Hi David!

Thank you too for your helping!
I like the idea of having a helper to convert to strings, thats great! Also, I 
didn't know about flatten, thats really interesting!

Basically my problem description was only the endpoint of what I wanted to 
archieve.
I'm using Racket right now happily to search through a sqlite database for 
personal learning.
For this I'm using query-rows from db. This returns a list of vectors.
At first I printed the results with a function that takes the vectors and 
transformed them into a human readable information, because I knowed how to 
iterate over a list, transform vectors and how to use the repl.

With your, and the other David's (sorry, could not resist!) help I'm able to 
put that onto a webapp what I will try next - after I managed to memorize und 
truly understanding that concepts. With those naive approach (playing with 
data) I'm learning quite good how all fits together.

You two really helped me to understand how it's meant to be used!

Thank you!
Gregor

-- 
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] Iterate over a list to construct a single string?

2016-10-13 Thread David Storrs
David Christiansen's answer was very detailed and thorough, but I wanted to
add one more.  If I understand it, your goal is to take an arbitrary
(possibly nested) list of strings and concatenate all the strings.  This
will do that:

(define lst '("foo" ("bar") ( ("baz") "jaz") ))
(string-append (flatten lst))  ;;  returns "foobarbazjaz"

'flatten' takes any S-expression (loosely, any list) and turns it into a
single one-level list.  For example, all of the following produce '(a b c d
e)

(flatten '(a b c d e))
(flatten '((a b) (c d) e))
(flatten '(  (((a (b (c d) e ))
(flatten '(a b (c ((d e))) ))

[Note that I used symbols instead of strings so as to avoid typing lots of
" characters, but same thing.]

(string-append (flatten lst)) will fail if there is anything in lst that is
not a string (e.g. a symbol, number, etc)  To fix that you could do the
following:

(define (to-str x)
(cond ((number? x) number->string)
  ((symbol?  x) symbol->string)
  (...other clauses as desired...)
(else identity)))

This is a function that takes one item, determines what type it is, and
then returns a function that will convert that type to a string.
'identity' is a function that takes any one item and returns that item
unchanged -- in this case it's being used as 'string->string'.

Now that you have to-str you can then take the function that it returns and
use it.  For example, try doing the following in the Racket REPL:

(define converter  (to-str "string_foo"))   ;; converter is now the
function 'identity'
(converter "string_foo")  ;; returns "string_foo"

(define converter  (to-str 'symbol_foo))   ;; converter is now the function
'symbol->string'
(converter 'symbol_foo) ;; returns "symbol_foo" [which is a string]

(define converter  (to-str 7))   ;; converter is now the function
'number->string'
(converter 7) ;; returns "7" [which is a string]


There are more types 
than I've included, but this should make the point.

At this point you can handle lists that contain non-string items:

(define lst '("foo" (bar "baz" 7) "jaz"))
(string-append (flatten lst))  ;; throws an exception because 'bar isn't a
string
(string-append (map to-str (flatten lst)))  ;; returns "foobarbaz7jaz"

Hope this helps,

Dave

On Thu, Oct 13, 2016 at 8:18 AM, Gregor Kopp  wrote:
> Hi!
>
> I'm very new to Racket and the lisp family generally, and very slowly
starting to get an idea how everything works together.
>
> Now my very first question ;)
>
> If I have a list of string's, how can i recursivly iterate over that list
and compose a single string out of the elements of that list?
>
> I prepared a simple example, so hopefully you can understand what I'm
talking about:
>
> (define mylist '("hello" "darkness" "my" "old" "fiend"))
>
> (for-each (lambda (elem)
>(displayln elem)
>)
>  mylist)
>
> It prints out every element of mylist as I expect in a new line.
> But what if I want to collect all strings into one single string, so that
I can  get "hellodarknessmyoldfriend"?
>
> I think I can use string-append, right?
> But how could I do that? Is there a idiomatic way to do that in Racket?
>
> Thank you very much for every input.
>
> Gregor
>
> --
> 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] Iterate over a list to construct a single string?

2016-10-13 Thread Gregor Kopp
Am Donnerstag, 13. Oktober 2016 14:38:14 UTC+2 schrieb David Christiansen:
> Hi Gregor,
> 
> > Now my very first question ;)
> >
> > If I have a list of string's, how can i recursivly iterate over that list 
> > and compose a single string out of the elements of that list?
>  >
>  > ...

Hi David, I'd like to thank you very much for your detailed explanations! I 
will work through all these options you've written!

Thank you!

Gregor

-- 
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 insert @ character into scribble-generated output?

2016-10-13 Thread Matthew Flatt
I recommend using |{ ... }|:

  @verbatim|{
@Test
public void checkHBLen() {
   assertEquals(HapBD.lenInSeconds, 25);
}
  }|


More details:
 http://docs.racket-lang.org/scribble/reader.html#%28part._alt-body-syntax%29

At Thu, 13 Oct 2016 08:42:13 -0500, Robby Findler wrote:
> You can do @"@" (i.e. escape to Racket with the first @ and then make
> a string that has an @ in it as the result of the escape).
> 
> Or you can change the @ character to another one, perhaps using pollen
> (it uses a diamond lozenge thingy).
> 
> Robby
> 
> 
> On Thu, Oct 13, 2016 at 8:20 AM, Kathi Fisler  wrote:
> > I need to put a sample of a JUnit test case in a sribble document, along 
> > the 
> lines of
> >
> >  @verbatim{
> >@Test
> >public void checkHBLen() {
> >   assertEquals(HapBD.lenInSeconds, 25);
> > }
> >   }
> >
> > What's the escape sequence for treating the @ on Test literally, rather 
> > than 
> as a scribble command.  Couldn't find this in the reader documentation.
> >
> > 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.

-- 
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 insert @ character into scribble-generated output?

2016-10-13 Thread Robby Findler
You can do @"@" (i.e. escape to Racket with the first @ and then make
a string that has an @ in it as the result of the escape).

Or you can change the @ character to another one, perhaps using pollen
(it uses a diamond lozenge thingy).

Robby


On Thu, Oct 13, 2016 at 8:20 AM, Kathi Fisler  wrote:
> I need to put a sample of a JUnit test case in a sribble document, along the 
> lines of
>
>  @verbatim{
>@Test
>public void checkHBLen() {
>   assertEquals(HapBD.lenInSeconds, 25);
> }
>   }
>
> What's the escape sequence for treating the @ on Test literally, rather than 
> as a scribble command.  Couldn't find this in the reader documentation.
>
> 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.


[racket-users] How to insert @ character into scribble-generated output?

2016-10-13 Thread Kathi Fisler
I need to put a sample of a JUnit test case in a sribble document, along the 
lines of

 @verbatim{
   @Test 
   public void checkHBLen() {
  assertEquals(HapBD.lenInSeconds, 25);
}
  }

What's the escape sequence for treating the @ on Test literally, rather than as 
a scribble command.  Couldn't find this in the reader documentation.

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] Iterate over a list to construct a single string?

2016-10-13 Thread David Raymond Christiansen

Hi Gregor,


Now my very first question ;)

If I have a list of string's, how can i recursivly iterate over that list and 
compose a single string out of the elements of that list?

>
> ...
>
> I think I can use string-append, right?
> But how could I do that? Is there a idiomatic way to do that in Racket?
>

In the special case where you have a list of strings, you can use 
"apply", as follows:


 (apply string-append mylist)

This works because "string-append" can take any number of arguments, and 
"apply" calls the procedure on the list of arguments.


In general, though, you may need to do iteration while accumulating. 
There's a few ways to do this. One is to write a recursive procedure:


(define (append-many-strings strings)
  (cond
[(null? strings) ""]
[else (string-append (car strings)
 (append-many-strings (cdr strings)))]))

To make this into real iteration, it should be transformed to be 
tail-recursive. This can be done with an accumulator:


(define (append-many-strings-tail strings acc)
  (cond
[(null? strings) acc]
[else (append-many-strings-tail (cdr strings)
(string-append acc (car strings)))]))

(append-many-strings-tail mylist "")

Because the recursive call to "append-many-strings-tail" occurs as the 
very last thing done in the procedure, it won't require stack space at 
runtime.


The pattern of replacing each "cons" in a list with a function call is 
captured in a procedure called foldr:


(define (append-many-strings-foldr strings)
  (foldr string-append "" strings))

(append-many-strings-foldr mylist)

This version is equivalent to append-many-strings above. This style is 
more common in other functional languages than it is in Racket, in my 
experience.


Probably the most idiomatic way to do it in Racket is with a for/fold form:

(define (append-many-strings-for/fold strings)
  (for/fold ([result ""])
([s strings])
(string-append result s)))

This version will work for inputs that are not a list, because for/fold 
can draw elements from any arbitrary kind of sequence. It also runs 
iteratively, without using lots of space at runtime.


I'd encourage you to check out the excellent documentation for each of 
these ways of doing it.


/David

--
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] Iterate over a list to construct a single string?

2016-10-13 Thread Gregor Kopp
Hi!

I'm very new to Racket and the lisp family generally, and very slowly starting 
to get an idea how everything works together.

Now my very first question ;)

If I have a list of string's, how can i recursivly iterate over that list and 
compose a single string out of the elements of that list?

I prepared a simple example, so hopefully you can understand what I'm talking 
about:

(define mylist '("hello" "darkness" "my" "old" "fiend"))

(for-each (lambda (elem)
   (displayln elem)
   )
 mylist)

It prints out every element of mylist as I expect in a new line.
But what if I want to collect all strings into one single string, so that I can 
 get "hellodarknessmyoldfriend"?

I think I can use string-append, right?
But how could I do that? Is there a idiomatic way to do that in Racket?

Thank you very much for every input.

Gregor

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