Re: [racket-users] a minor regexp question (and a how-could-I-answer-it-myself? question)

2020-05-01 Thread Tim Hanson
Thanks, Jens, much appreciated. I suspect I even knew this once and had since 
forgotten it.

(I even glanced at the docs, saw the two kinds, but didn’t pause long enough to 
wonder if it mattered to me.)

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/69320674-8272-4751-a6ce-40c140a7358c%40googlegroups.com.


[racket-users] a minor regexp question (and a how-could-I-answer-it-myself? question)

2020-05-01 Thread Tim Hanson
hi, just now I'm debugging a regular expression and trying to understand why 
this:

  > (regexp-match-positions #rx"[-+][0-9]+" "-0500")
  '((0 . 5))

works as I expect, whereas this:

  > (regexp-match-positions #rx"[-+][0-9]{4}" "-0500")
  #f

doesn't. (My naive opinion is the second expression should return the same 
answer as the first.)



Wondering whether I could discover for myself whether this is a known issue, I 
found directly:

  https://github.com/racket/racket/search?q=regexp=Issues

or perhaps something like this:

  
https://github.com/racket/racket/search?q=regexp+type%3Aissue_q=regexp+type%3Aissue

is better, but either way I'm quickly pretty lost in terms of deciding whether 
this relates to a known issue.


I'd appreciate advice on either question.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/061c9f78-0ffe-4a5e-be12-10518d70c413%40googlegroups.com.


Re: [racket-users] a question or two regarding Gregor

2020-05-01 Thread Tim Hanson
very helpful that you linked to the issue, thank you. I now understand there 
are non-trivial problem domain issues (for example, “CDT” is ambiguous, 
probably even with locale specified.)

I will think about how to tackle my specific problem and whether I can help 
with issues like these.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/3cdc53af-be4f-48c3-9901-72b15751023d%40googlegroups.com.


Re: [racket-users] a question or two regarding Gregor

2020-04-30 Thread Tim Hanson
Thanks for the quick reply, Jon!

OK, good to know. Maybe I can add the ones I need (if I can figure out how...). 
:)

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/71a39eaa-7714-47fb-9d24-0d151ae93060%40googlegroups.com.


Re: [racket-users] a question or two regarding Gregor

2020-04-30 Thread Tim Hanson
p.s. I'm stuck on parsing one pattern that comes up in my data. Here's a 
corresponding test:

  (parameterize ([current-locale "en"])
(check-equal?
 (parse-datetime "Sun, 21 Jun 2015 17:50:44 -0500 (CDT)" "EEE, dd MMM 
 HH:mm:ss  ()") (datetime 2015 6 21 17 50 44)))

that fails with
../../../../../Library/Racket/7.6/pkgs/gregor-lib/gregor/private/pattern/ast/zone.rkt:40:2:
 match: no matching clause for (Zone ... 'offset-name 'long)


I'm looking at the source code but am not quite sure. Are zone descriptors such 
as CDT supported? (I also tried (zzz), but it also fails with 
no matching clause for (Zone ... 'offset-name 'short).)


In 
  https://unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns

I find an example:

Pattern Result (in a particular locale)
.MM.dd G 'at' HH:mm:ss zzz  1996.07.10 AD at 15:08:56 PDT

which makes me think it should perhaps work.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/10f6f25d-6da8-4bbb-9459-ce63ae071c34%40googlegroups.com.


Re: [racket-users] a question or two regarding Gregor

2020-04-28 Thread Tim Hanson
Thanks, Jon!

I agree with your analysis and thoughts about which cases should always raise 
exceptions. (I can't recall whether you scan patterns that include 
semi-redundant information such as day-of-week; wondered just now whether a 
contradictory day of week would be another category of exception -- or whether 
you just ignore it.)

I guess I will try an approach like the one Ben posted for now, just to find 
out how many patterns turn up.

Later I'd be interested in an elegant way to pre-test "parse-ability", though I 
have a healthy respect for the effort involved. 

(And you've done a great job, I think, of keeping just what is needed and 
hiding lots of details in the "private" sections. One doesn't want to add more 
than is needed.)

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/b3120b5f-1c5b-4e34-b342-6cd12ef27aba%40googlegroups.com.


Re: [racket-users] a question or two regarding Gregor

2020-04-27 Thread Tim Hanson
Thanks. Something like that will let me proceed for now.

I'd still be curious what folks think about an approach avoiding exceptions.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/7bf167d1-b96d-42ba-9c53-5401e811eed9%40googlegroups.com.


[racket-users] a question or two regarding Gregor

2020-04-27 Thread Tim Hanson
hi, I've installed and am trying out 

  Gregor: a date and time library for Racket

and find it to be very powerful and useful.

In my current application (digging through mail headers) I'm wondering whether 
there is a way to test whether a given date-time format matches without using 
exceptions. (I assume that would generally be more efficient than catching 
exceptions.)

I've forked https://github.com/97jaz/gregor

and successfully added a couple of tests that work to tests/parse.rkt:

 (test-suite
  "some datetime particulars"
  (check-equal?
   (parse-datetime "2015-03-15T02:02:02-04:00" "-MM-dd'T'HH:mm:ssxxx") 
(datetime 2015 3 15 2 2 2))

  (parameterize ([current-locale "en"])
(check-equal?
 (parse-datetime "21 Jun 2015 15:45:40" "dd MMM  HH:mm:ss") 
(datetime 2015 6 21 15 45 40)))

  (check-exn
   exn:gregor:parse?
   (lambda ()
 (parse-datetime  "21 Jun 2015 15:45:40 -" 
"-MM-dd'T'HH:mm:ssxxx")))
)


I'd like to add something along these lines:

  (check-equal?
   (parsable-as-datetime? "2015-03-15T02:02:02-04:00" 
"-MM-dd'T'HH:mm:ssxxx")
   #t)
  (check-equal?
   (parsable-as-datetime?"21 Jun 2015 15:45:40 -" 
"-MM-dd'T'HH:mm:ssxxx")
   #f)

but implementing them would take me longer than I have at the moment. (Maybe 
using an err lambda that doesn't throw an exception?)

I thought I'd check here: 
- does this seem like a reasonable idea?
- is mine an unusual use case and most folks know what format to expect and the 
exception approach is fine?
- is there perhaps an elegant way for me to test with a regular expression 
first rather than adding this function to Gregor?

Cheers,

Tim

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/64c02e43-f693-475b-a8f4-05cf8f622c25%40googlegroups.com.


Re: [racket-users] question re downloading a PDF file

2019-11-24 Thread Tim Hanson
Thanks, Dominik,

that appears to do the trick! (pdfgrep is immediately happy...).

Much appreciated,

Tim

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/b117ca57-d32f-44ba-a1fb-1185a23e3442%40googlegroups.com.


[racket-users] question re downloading a PDF file

2019-11-24 Thread Tim Hanson
hi,

I need to fetch a number of PDF documents and wrote a bit of racket to make it 
easier. The part that "downloads" is this:

(let ([content 
   ((compose port->string get-pure-port string->url) (url-for-doc year 
doc-name))])
  (let ([out (open-output-file full-path-of-file-to-write #:mode 'text)])
(write-string content out)
(close-output-port out)

According to the file utility the resulting file is a

  PDF document, version 1.7

But I can't open it with preview on a mac ("it may be damaged or use a format 
that preview doesn't recognize");  pdfgrep ("cannot open") and pdf2ps (
    Error:  An error occurred while reading an XREF table.
    The file has been damaged.  This may have been caused
    by a problem while converting or transfering the file.
) also complain.

Using mac file system info (command i) I notice differences when I examine a 
file downloaded this way versus one I got using save-as with a browser. The 
file I download with racket shows nothing in the "More info" section. The 
version downloaded with a browser shows about 10 fields. Is there something 
outside the file I need to worry about? (Once upon a time mac files had data 
and resource forks -- maybe they still do?)

Should I be using some other method of downloading? (Incidentally I also tried 
#:mode 'binary.)

Might I have more luck under gnu linux?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/3d5eb9a0-c0b8-4eea-9af9-05cdd920ed54%40googlegroups.com.


[racket-users] macOSX trick linking drracket in dock to current version via /etc/paths.d/racket ?

2019-11-17 Thread Tim Hanson
hi, 

I just upgraded to 7.4 and rediscovered (here, thanks for helpful posts!) the 
best practice for the bash $PATH using /etc/paths.d/racket.

Is there an analogous trick to "update" which version I get when I click on the 
drracket icon in the macOSX dock? (OK, it's only a few clicks to remove it and 
re-add it from /Applications/...7.4/bin/drracket ...).

I also searched roughly "programmatically add adjust macOSX dock icon" but 
nothing conclusive popped out at me.

Sincerely,

Lazy but Curious :)

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/aa70ee6f-1f38-4829-a1f4-02d8a40441bf%40googlegroups.com.


Re: [racket-users] go cheney yourself

2019-01-08 Thread Tim Hanson
Sorry! Yes, wrong list; noticed immediately; deleted immediately, butI guess 
that doesn’t stop the mails.

Mea maxima culpa.

I’ll try to be more careful in the future.

Tim


> On Jan 8, 2019, at 10:37 PM, Matthias Felleisen  
> wrote:
> 
> 
> This is totally inappropriate. 
> 
> 
>> On Jan 8, 2019, at 4:09 PM, Tim Hanson  wrote:
>> 
>> great piece by Michelle Goldberg, imho:
>> 
>> https://www.nytimes.com/2019/01/07/opinion/rashida-tlaib-profanity.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.


[racket-users] go cheney yourself

2019-01-08 Thread Tim Hanson
great piece by Michelle Goldberg, imho:

https://www.nytimes.com/2019/01/07/opinion/rashida-tlaib-profanity.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.


Re: [racket-users] a matrix question

2018-03-26 Thread Tim Hanson
Many thanks, Jens Axel! That looks very good and includes several techniques 
that will help and inspire me, in particular for*/matrix, which I hadn't used 
yet.

I'll try it out the next chance I get.

-- 
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] a matrix question

2018-03-25 Thread Tim Hanson
hi, 

I'm trying out matrices (without typed racket, though I read the performance 
caveat -- I'm not worried about performance at the moment) and am trying to 
find the best idioms for a small function I'd like to build.

Q1: is there an elegant away to assemble a matrix column-wise? (my first draft 
solution is to read one col-matrix and write cell by cell into a destination 
(mutable) matrix); my preference would be to use immutable items, but that's 
secondary to elegance at this point.

cheers,

Tim

-- 
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] "Site not secure"

2018-03-10 Thread Tim Hanson
Thanks for fixing it!

-- 
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] "Site not secure"

2018-03-09 Thread Tim Hanson
Hi, I tried to grab the latest racket version from download.racket-lang.org and 
chrome and edge tell me the certificate of the site at mirror.racket-lang.org 
is not yet valid or expired. It's no problem as I found a mirror with a valid 
certificate, but I guess you'll want to renew the certificate.

Cheers, tim

-- 
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] catching a contract violation in a unit test with check-exn

2017-11-25 Thread Tim Hanson
Thanks again. 

I've tweaked and commented the end of Mathias's example:

(module+ test
  (check-exn exn:fail:contract? (lambda () (f 1))) ; violates contract by 
returning non-integer
  (check-exn exn:fail:contract? (lambda () (f 'a ; violates contract by 
being called with a non-integer

and "thunking" makes my example work as I wanted:

(check-exn
 exn:fail:contract?
 (lambda () 
   (stream-first
(pairwise-stream (stream-cons 1 empty-stream)

-- 
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] catching a contract violation in a unit test with check-exn

2017-11-18 Thread Tim Hanson
Beautiful! Thanks to both of you. Can't wait to try it out.
Cheers,
Tim

-- 
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] catching a contract violation in a unit test with check-exn

2017-11-18 Thread Tim Hanson
Hi, I guess this didn't find the right subject matter expert yet. Would it be 
better to ask a specific person or use a different channel?
Cheers, tbh

-- 
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] catching a contract violation in a unit test with check-exn

2017-11-12 Thread Tim Hanson
hi,

As part of something I'm working on I want to convert a stream of values 
into a stream of pairs of values, e.g.

  1 2 3 4

becomes
  (1 2) (3 4)

The following seems to work fine:

(define (pairwise-stream astream)
  (if (stream-empty? astream)
  empty-stream
  (stream-cons
   (cons
(stream-first astream)
(stream-first (stream-rest astream)))
   (pairwise-stream
(stream-rest (stream-rest astream))

but I'd like my 2nd or 3rd test to detect a problem with a stream of odd 
length and haven't figured out how yet. Here's my attempt (lengths 0 and 2 
work fine, length 1 shows a contract violation, but my test doesn't detect 
it):

(check-equal?
 (stream->list
  (pairwise-stream empty-stream))
 (stream->list empty-stream))

; hmmm, how to detect this correctly?
;(check-exn
; exn:fail:contract?
; (stream-first
;  (pairwise-stream (stream-cons 1 empty-stream

(check-equal?
 (stream->list (pairwise-stream (stream-cons 1 (stream-cons 2 
empty-stream
 (stream->list (stream-cons (cons 1 2) empty-stream)))

I'd be grateful for advice.

Cheers,

Tim

-- 
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] Hint on opening enclosing directory of current file from DrRacket

2017-06-29 Thread Tim Hanson
Heh, cool, Laurent! This dabbler had missed this until now -- I will read and 
probably use.

Cheers, tim

-- 
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] [Racket-users] IMAP with racket

2017-02-11 Thread Tim Hanson
p.s. I just found this:
  
https://planet.racket-lang.org/package-source/gh/gapi.plt/1/3/planet-docs/manual/Examples.html

which leads here:
  
https://github.com/greghendershott/gapi/blob/master/examples/macro/gplus-oauth.rkt

and looks promising. (I didn't find any signs of oauth use in sirmail (or for 
that matter in racket on github, but I probably don't know where to look)).

I found this:
  
https://pkgs.racket-lang.org/#(!deprecated)(!main-distribution)(!main-tests)(oauth)

Why does google rely on / require a thing which is an emerging standard and 
still unstable?

-- 
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] [Racket-users] IMAP with racket

2017-02-11 Thread Tim Hanson
Bravo! This parallels my motivation. I'm kind of a beginner in Racket, but it 
is powerful, portable, elegant, well-documented, and well-supported, so I keep 
dabbling ...

-- 
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] IMAP with racket

2017-02-11 Thread Tim Hanson
Thanks, all, this rings a bell and I note that:

  https://docs.racket-lang.org/webapi/oauth2.html

says use with caution. I will look around and see if I can figure out how to do 
imap in conjunction with oauth2.

Cheers,

Tim

-- 
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] IMAP with racket

2017-02-11 Thread Tim Hanson
Thanks again for several helpful pointers. I've recorded humble beginnings here:

  https://github.com/tbhanson/imap-with-racket

Comments and suggestions very welcome. (I know in particular I'd like to have a 
handy way to store my credentials somewhere, am using ~/.myImapCreds for now, 
but am unsure whether to keep server connection details in the same place or a 
kind of parallel place.) 

I have successfully connected to two of the mail servers I use this way, but 
not yet to gmail. Has anyone successfully connected to gmail using either of 
the approaches tested here? Maybe someone can point out what I'm doing wrong? 

(I remember gmail was finicky a while back when I tried connecting to it using 
Thunderbird; at some point it broke, with google warning some insecure app was 
trying to access my mail (same thing happens with my racket attempts so far). I 
was later able to connect after sufficiently upgrading Thunderbird. (More at 
https://support.mozilla.org/t5/Set-up-email/Thunderbird-and-Gmail/ta-p/14181)).

-- 
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] IMAP with racket

2017-02-08 Thread Tim Hanson
Cool, thank you! I had no idea about parameterize. I will try that and continue 
my investigations.

-- 
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] IMAP with racket

2017-02-08 Thread Tim Hanson
P.s. For that matter couldn't folder also be optional, defaulting to "INBOX"?

-- 
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] IMAP with racket

2017-02-07 Thread Tim Hanson
hi, I'm finally finding time to dig into this a little and have a question about

  
https://docs.racket-lang.org/net/imap.html#%28def._%28%28lib._net%2Fimap..rkt%29._imap-port-number%29%29

Does this make imap-port-number a kind of global variable? My naive view is it 
would be somewhat friendlier to make it an optional parameter to imap-connect 
along the lines of

  [ #:tls? tls?  
#:try-tls? try-tls?]

but defaulting to 143. 

Does it become an attribute of an open imap-connection or does it remain a 
global, say if I hypothetically had two imap-connections going at once? 

I will experiment and maybe learn more, but thought I'd ask about this in the 
meantime.

Cheers,

Tim

-- 
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] IMAP with racket

2016-12-27 Thread Tim Hanson
Thanks for both answers! I'll report back when I've made some progress!

Cheers,

Tim

-- 
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] IMAP with racket

2016-12-26 Thread Tim Hanson
Hi, I think I'd like to try using racket as a way to explore relatively simple 
ways of getting a grip on some mail accounts that have gotten out of hand. 
Specifically I'd like to be able to
- compute some statistics, such as number of mails from various addresses
- reorganize / clean-up, say by moving mails into folders according to rules or 
deleting mails from specific senders older than a given amount

I have done similar things in the past using built-in functions in mail clients 
such as outlook or entourage. (If thunderbird supports such functions I could 
use that now, but I haven't found clues that it does; I even looked at 
AppleScript and began using it to explore, but quickly got pretty frustrated 
with the language and its documentation.)

I like racket, though, and it would seem to be great to be able to try out 
functions interactively in the REPL.

My impression on first glance though, was that the built-in IMAP support would 
require quite a bit of assembly and additions. I also found SirMail, which 
looks like more than what I need, though presumably I could make use of its 
foundation parts if I could figure out which and how.

Might it be appropriate to build something between the IMAP basics and SirMail? 
Alternatively, is there a brief how-to for SirMail? I found the sources on 
github and they seemed to work immediately, but I have some questions about 
set-up. Perhaps I could even help write a brief "how to" with input from the 
authors?

 (Maybe there are more appropriate, "easier" ways of doing what I want to do 
that others think of immediately, in which case clues would be appreciated.)

-- 
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] reading UTF-16 from a file

2015-11-13 Thread Tim Hanson
hi,

I was hoping yesterday to read UTF-16 characters from a file using, e.g., a 
small snippet such as the following:

(for ([c (in-port read-char (open-input-file "myfile.txt"))]
  [counter naturals]
  #:break (>= counter 100))
  (printf "(~a [~a]) " c (char->integer c)))

For a UFT-16 file (that came from windows and perhaps for that reason has a 
byte order mark -- not sure) that be begins "11 Nov" I got:

(� [65533]) (� [65533]) (1 [49]) (  [0]) (1 [49]) (  [0]) (  [32]) (  [0]) (N 
[78]) (  [0]) (o [111]) (  [0]) (v [118]) (  [0])

I suspect I need to do something with encodings, but I wasn't able to figure it 
out with a quick scan through documentation and searches in this group. Perhaps 
someone could give me a quick nudge in the right direction?

Cheers,

Tim


p.s. maybe there's an easier way to get an arbitrary counter than what i did 
here?

(define (integers-starting-from n)
  (stream-cons
   n
   (integers-starting-from (+ n 1
   
(define naturals
  (integers-starting-from 1))

This worked fine for me, so I didn't worry about it...

-- 
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: regexp question

2015-10-31 Thread Tim Hanson
On Friday, October 30, 2015 at 10:35:19 PM UTC+1, Matthew Butterick wrote:
> [[:space:]] and similar matchers also require #px.
> 
> As for the difference between #rx and #px:
> 
> "The pregexp ... procedures produce a regexp value using a slightly different 
> syntax of regular expressions that is more compatible with Perl."
> 
> That must be the only thing in Racket influenced by Perl.
> 
> 
> 
> 
> On Friday, October 30, 2015 at 11:46:27 AM UTC-7, Tim Hanson wrote:
> > On Friday, October 30, 2015 at 7:21:58 PM UTC+1, Matthew Butterick wrote:
> > > To use \s as a matcher, you need #px not #rx:
> > > 
> > > (define rx-empty-or-all-blank-string
> > >   ;#rx"^[[:space:]]*$")
> > >   #px"^\\s*$")
> > > 
> > > See 
> > > http://docs.racket-lang.org/reference/regexp.html?q=pregexp#%28elem._%28rxex._25%29%29
> > > 
> > > 
> > > On Friday, October 30, 2015 at 11:15:08 AM UTC-7, Tim Hanson wrote:
> > > > hi,
> > > > 
> > > > I must be overlooking something basic, but can't figure out why the 
> > > > second and third tests here fail. (Makes no difference whether I spell 
> > > > {space-character} the [[:space:]] or the \\s way.)
> > > > 
> > > > I'd be grateful for enlightenment. :)
> > > > 
> > > > Cheers,
> > > > 
> > > > Tim
> > > > 
> > > > (define rx-empty-or-all-blank-string
> > > >   ;#rx"^[[:space:]]*$")
> > > >   #rx"^\\s*$")
> > > > 
> > > > (check-equal? (regexp-match? rx-empty-or-all-blank-string "") #t)
> > > > 
> > > > (check-equal? (regexp-match? rx-empty-or-all-blank-string " \t ") #t)
> > > > 
> > > > (check-equal? (regexp-match? rx-empty-or-all-blank-string " \t\n") #t)
> > 
> > ok, thx muchly. saw #px but didn't see the explanation / distinction.
> > 
> > if it's easy to explain, why does the other one also fail?
> > 
> > cheers,
> > 
> > Tim

Ok, thanks, much. The examples were quite dense and I didn't read them 
completely (I have quite a bit of regexp experience in other settings), but now 
I see the helpful comments re #px on the right. All my tests went green the 
moment I switched to #px (not just these), so I am a happy camper.

Cheers,

Tim

-- 
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: regexp question

2015-10-30 Thread Tim Hanson
On Friday, October 30, 2015 at 7:21:58 PM UTC+1, Matthew Butterick wrote:
> To use \s as a matcher, you need #px not #rx:
> 
> (define rx-empty-or-all-blank-string
>   ;#rx"^[[:space:]]*$")
>   #px"^\\s*$")
> 
> See 
> http://docs.racket-lang.org/reference/regexp.html?q=pregexp#%28elem._%28rxex._25%29%29
> 
> 
> On Friday, October 30, 2015 at 11:15:08 AM UTC-7, Tim Hanson wrote:
> > hi,
> > 
> > I must be overlooking something basic, but can't figure out why the second 
> > and third tests here fail. (Makes no difference whether I spell 
> > {space-character} the [[:space:]] or the \\s way.)
> > 
> > I'd be grateful for enlightenment. :)
> > 
> > Cheers,
> > 
> > Tim
> > 
> > (define rx-empty-or-all-blank-string
> >   ;#rx"^[[:space:]]*$")
> >   #rx"^\\s*$")
> > 
> > (check-equal? (regexp-match? rx-empty-or-all-blank-string "") #t)
> > 
> > (check-equal? (regexp-match? rx-empty-or-all-blank-string " \t ") #t)
> > 
> > (check-equal? (regexp-match? rx-empty-or-all-blank-string " \t\n") #t)

ok, thx muchly. saw #px but didn't see the explanation / distinction.

if it's easy to explain, why does the other one also fail?

cheers,

Tim

-- 
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] regexp question

2015-10-30 Thread Tim Hanson
hi,

I must be overlooking something basic, but can't figure out why the second and 
third tests here fail. (Makes no difference whether I spell {space-character} 
the [[:space:]] or the \\s way.)

I'd be grateful for enlightenment. :)

Cheers,

Tim

(define rx-empty-or-all-blank-string
  ;#rx"^[[:space:]]*$")
  #rx"^\\s*$")

(check-equal? (regexp-match? rx-empty-or-all-blank-string "") #t)

(check-equal? (regexp-match? rx-empty-or-all-blank-string " \t ") #t)

(check-equal? (regexp-match? rx-empty-or-all-blank-string " \t\n") #t)

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