Re: [racket-users] Re: appending files

2016-01-29 Thread Jon Zeppieri
On Fri, Jan 29, 2016 at 7:04 PM, Scotty C wrote: > > > question for you all. right now i use modulo on my bignums. i know i > > > can't do that to a byte string. i'll figure something out. if any of > > > you know how to do this, can you post a method? > > > > > > > I'm not

Re: [racket-users] Re: appending files

2016-01-29 Thread Jon Zeppieri
On Fri, Jan 29, 2016 at 7:45 PM, Scotty C wrote: > > my plan right now is to rework my current hash so that it runs byte > strings instead of bignums. > > i have a new issue. i wrote my data as char and end records with 'return. > i use (read-line x 'return) and the first

Re: [racket-users] Racket performance tips

2016-01-17 Thread Jon Zeppieri
My string-trim uses unsafe ops, but I'm pretty sure it's safe. The (safe) string-length at the start ensures we're using a string. The rest are indexing and fixnum arithmetic on integers that are guaranteed to be valid indices of the string. Still, if you don't like this, replace the unsafe

Re: [racket-users] Racket performance tips

2016-01-17 Thread Jon Zeppieri
re efficient implementations of > relevant operations here, and Ruby's might too. > > Robby > > > On Sun, Jan 17, 2016 at 2:00 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: > > My string-trim uses unsafe ops, but I'm pretty sure it's safe. The > (safe) string-length at the

Re: [racket-users] Racket performance tips

2016-01-17 Thread Jon Zeppieri
f > relevant operations here, and Ruby's might too. > > Robby > > > On Sun, Jan 17, 2016 at 2:00 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: > > My string-trim uses unsafe ops, but I'm pretty sure it's safe. The > (safe) string-length at the start ensures we're using

Re: [racket-users] Store value with unsupported type in Postgres?

2016-01-17 Thread Jon Zeppieri
How about: (query-exec conn (format "INSERT INTO some_table (ip) VALUES (inet '~a')" client-ip)) On Sun, Jan 17, 2016 at 6:35 PM, Alexis King wrote: > The DB docs for SQL type conversions[1] note that not all Postgres types > are supported by Racket, and it recommends

Re: [racket-users] Store value with unsupported type in Postgres?

2016-01-17 Thread Jon Zeppieri
1-17 7:35 PM, Alexis King wrote: >> I would like to avoid interpolating into a query if at all possible, >> given that this string is not something I control. I could be very >> careful about validating or sanitizing it, but this is a pretty textbook >> use case for parameteri

Re: [racket-users] Store value with unsupported type in Postgres?

2016-01-17 Thread Jon Zeppieri
idating or sanitizing it, but this is a pretty textbook > use case for parameterized queries. > >> On Jan 17, 2016, at 16:19, Jon Zeppieri <zeppi...@gmail.com> wrote: >> >> How about: (query-exec conn (format "INSERT INTO some_table (ip) VALUES >> (inet '~a')" clien

Re: [racket-users] How can I build up the #:usage-help string dynamically in racket lang's (command-line …) function?

2016-01-17 Thread Jon Zeppieri
I think you'll need to use parse-command-line, instead of command-line. -J On Sun, Jan 17, 2016 at 7:51 AM, Pieter Breed wrote: > Hi All, > > (I'm cross-posting this from StackOverflow) > http://stackoverflow.com/q/34837318/24172 > > I have this code: > > (define s1

Re: [racket-users] Racket performance tips

2016-01-16 Thread Jon Zeppieri
On Sat, Jan 16, 2016 at 11:29 PM, Brian Adkins wrote: > > I'm happy to run experiments and report timings though. > > Since the profile suggests that string-trim is the biggest culprit (followed by fprintf), try using this specialized version of string-trim locally: ;;

Re: [racket-users] Calling a procedure without allowing it to permanently alter parameters.

2016-01-12 Thread Jon Zeppieri
I don't think there is a better way than what you have. I looked into the undocumented `reparameterize` procedure, from '#%paramz: [ https://github.com/racket/racket/blob/a6eb00a41cc29859424335f40ef9ae68c471c57a/racket/src/racket/src/thread.c#L7680], but it only copies built-in parameters, so it

Re: [racket-users] Is there a way to return no value?

2015-12-11 Thread Jon Zeppieri
On Fri, Dec 11, 2015 at 5:27 PM, David Storrs wrote: > > > On Fri, Dec 11, 2015 at 1:53 PM, Matthew Butterick > wrote: >> >> PS. I'm assuming that you're using `eq?` here in deliberate preference to >> `equal?`. Because `eq?` is not reliable for

Re: [racket-users] Contract error when installing Gregor

2015-11-03 Thread Jon Zeppieri
Ok, I just pushed an update to the tzinfo package. It make take a little while for the package catalog to notice the change. -Jon On Tue, Nov 3, 2015 at 6:59 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: > On Tue, Nov 3, 2015 at 6:44 PM, William J. Bowman > <w...@williamjbo

Re: [racket-users] Contract error when installing Gregor

2015-11-03 Thread Jon Zeppieri
On Tue, Nov 3, 2015 at 6:44 PM, William J. Bowman <w...@williamjbowman.com> wrote: > On Tue, Nov 03, 2015 at 06:37:59PM -0500, Jon Zeppieri wrote: >> Okay, that is odd. I'll try reinstalling from scratch on my own machine to >> make sure I didn't introduce a bug at some poi

Re: [racket-users] Contract error when installing Gregor

2015-11-03 Thread Jon Zeppieri
On Tue, Nov 3, 2015 at 8:07 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: > Ok, I just pushed an update to the tzinfo package. It make take a > little while for the package catalog to notice the change. > Actually, the package catalog already noticed it, so you should be

Re: [racket-users] Contract error when installing Gregor

2015-11-03 Thread Jon Zeppieri
What OS are you using, and to you happen to know if/where the zoneinfo database is on your system? If the problem is that your database is in a location that Gregor doesn't expect, I'll be happy to fix that. If you don't have the database, at all (which would be odd for a modern UNIX), you can

Re: [racket-users] Contract error when installing Gregor

2015-11-03 Thread Jon Zeppieri
/zoneinfo. > On Nov 3, 2015, at 6:20 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: > > > What OS are you using, and to you happen to know if/where the zoneinfo > database is on your system? If the problem is that your database is in a > location that Gregor doesn't expe

Re: [racket-users] Contract error when installing Gregor

2015-11-03 Thread Jon Zeppieri
man <w...@williamjbowman.com> wrote: > > I'm running Arch Linux, and the zoneinfo database is in /usr/share/zoneinfo. > > -- > William J. Bowman > >> On Tue, Nov 03, 2015 at 06:20:54PM -0500, Jon Zeppieri wrote: >> >> What OS are you using, an

Re: [racket-users] DrRacket indentation adds spaces to empty non-top-level lines?

2015-10-21 Thread Jon Zeppieri
DrWhitespace will certainly remove spaces from empty non-top-level lines. (And from other places, as well.) -J On Wed, Oct 21, 2015 at 4:23 PM, Alexis King wrote: > This might be a relevant thread: > https://groups.google.com/d/msg/racket-users/5pxs1pM-8lE/uh0yn9D0QHYJ >

[racket-users] Re: [ann] gregor (date + time library) updates

2015-08-31 Thread Jon Zeppieri
[I'm unaccountably happy about the fact that the gregor docs on pkg-build.racket-lang.org reveal that they were scribbled on a machine in the America/Denver time zone. -J] On Mon, Aug 31, 2015 at 9:33 AM, Jon Zeppieri <zeppi...@gmail.com> wrote: > I've added a couple of features

[racket-users] [ann] gregor (date + time library) updates

2015-08-31 Thread Jon Zeppieri
I've added a couple of features to gregor: - Calendar query functions: [http://pkg-build.racket-lang.org/doc/gregor/query.html] These are functions that were already used internally by the library but should be public (and now are). - leap-year? - days-in-year - days-in-month -

Re: [racket-users] problems with sql-timestamp and date*

2015-08-22 Thread Jon Zeppieri
On Sat, Aug 22, 2015 at 4:02 PM, Jon Zeppieri zeppi...@gmail.com wrote: (require gregor) (require racket/match) (define (sql-timestamp-moment t) (match-define (sql-timestamp y mo d h mi s n tz) t) (moment y mo d h mi s n #:tz (or tz 0))) Actually, a sql-timestamp with a #f tz means

Re: [racket-users] problems with sql-timestamp and date*

2015-08-22 Thread Jon Zeppieri
Where exactly do you see sql-timestamp-srfi-date failing? In your examples, what I'm seeing is incorrect translation from UTC to UTC-4, but I don't see where the translation from sql-timestamp to date* is going wrong. Could you point to exactly where you see the problem? As far as offsetting time

Re: [racket-users] problems with sql-timestamp and date*

2015-08-22 Thread Jon Zeppieri
On Sat, Aug 22, 2015 at 5:50 PM, Jon Zeppieri zeppi...@gmail.com wrote: On Sat, Aug 22, 2015 at 4:36 PM, George Neuner gneun...@comcast.net wrote: [Sorry, I bungled the this part of the email.] Maybe I'm confused, but my understanding is that the database timestamp is in UTC, and you want

Re: [racket-users] problems with sql-timestamp and date*

2015-08-22 Thread Jon Zeppieri
On Sat, Aug 22, 2015 at 4:36 PM, George Neuner gneun...@comcast.net wrote: The latter code using date works properly (modulo the time zone field) and gives consistent results, but the former using date* gives inconsistent results. E.g.,: with timezone = -5 = expires #(struct:sql-timestamp

Re: [racket-users] For/lists: where is #:continue?

2015-07-13 Thread Jon Zeppieri
I think you're looking for #:when / #:unless. On Mon, Jul 13, 2015 at 3:12 PM, Pekka Niiranen pekka.niira...@pp5.inet.fi wrote: Hello users, What is the proper design pattern to skip invalid values when using for/list? The programs below fails because #:continue is not recognized:

Re: [racket-users] For/lists: where is #:continue?

2015-07-13 Thread Jon Zeppieri
Also, since you're not actually interested in the value of i, you should probably use in-vector rather than in-range. The whole example would be: (for/list ([value (in-vector vector)] #:when ( 0 (length value))) value) On Mon, Jul 13, 2015 at 3:18 PM, Jon Zeppieri zeppi

Re: [racket-users] For/lists: where is #:continue?

2015-07-13 Thread Jon Zeppieri
(string-split (vector-ref vector i) ,)) (col# (length columns))) (if ( 2 col#) (first columns) empty))) On 7/13/15 10:26 PM, Jon Zeppieri wrote: Also, since you're not actually interested in the value of i, you should probably use in-vector rather than in-range

Re: [racket-users] How to specify fallbacks for generic interfaces without going into an infinite loop?

2015-07-06 Thread Jon Zeppieri
Use define/generic: #lang racket/base (require racket/generic) (define-generics foo (a foo) (b foo) (c foo) #:fallbacks [(define/generic gen-a a) (define/generic gen-b b) (define (a foo) (displayln a-fallback) (gen-b foo)) (define (b foo) (displayln b-fallback)

Re: [racket-users] Re: Converting a heterogenous list into a string

2015-06-21 Thread Jon Zeppieri
On Sun, Jun 21, 2015 at 7:36 PM, Matthias Felleisen matth...@ccs.neu.edu wrote: I think the proper way of thinking Racket-y is to re-consider the input representation: (define our-list '((a 1) (b 2.5) (c #t) (d hi))) (string-join (map (match-lambda [`(,l ,v) (format [~a=~a] l v)])

Re: [racket-users] Re: Converting a heterogenous list into a string

2015-06-21 Thread Jon Zeppieri
On Sun, Jun 21, 2015 at 7:13 PM, Bahman Movaqar b.mova...@gmail.com wrote: On Monday, 22 June 2015 02:34:43 UTC+4:30, Bahman Movaqar wrote: Assuming (define my-list (a 1 b 2.5 c #t d hi)) what is the idiomatic way to convert `my-list` into the following? [a=1][b=2.5][c=#t][d=hi]

Re: [racket-users] Re: Fast way to map over a list many times, changing ONE element each time?

2015-06-21 Thread Jon Zeppieri
If you're willing to use vectors, then maybe you're also willing to use a custom data structure? You could get much better performance that way. Here's a half-baked example of what I mean. `map-once/h`, below, returns a (normal list) of hole-lists. (hole-list is not a good name. The offset doesn't

Re: [racket-users] Fast way to map over a list many times, changing ONE element each time?

2015-06-19 Thread Jon Zeppieri
It's unlikely that an implementation using continuations would be faster than one that does not. An idiomatic solution might look like: (define (map-once fn xs) (for/list ([i (in-range (length xs))]) (for/list ([(x j) (in-indexed (in-list xs))]) (cond [(= i j) (fn x)]

Re: [racket-users] prop:procedure, prop:match-expander, and contract blame

2015-04-16 Thread Jon Zeppieri
On Thu, Apr 16, 2015 at 7:32 AM, Alexander D. Knauth alexan...@knauth.org wrote: On Apr 15, 2015, at 2:29 PM, Jon Zeppieri zeppi...@gmail.com wrote: I'm trying to provide a struct, the struct type of which uses prop:procedure and prop:match-expander, and I'd like the procedure to have

Re: [racket-users] prop:procedure, prop:match-expander, and contract blame

2015-04-16 Thread Jon Zeppieri
On Thu, Apr 16, 2015 at 8:02 AM, Jon Zeppieri zeppi...@gmail.com wrote: On Thu, Apr 16, 2015 at 7:32 AM, Alexander D. Knauth alexan...@knauth.org wrote: By the way, why wouldn’t you just use define-match-expander instead of defining the B struct? Because I need the same identifier

Re: [racket-users] prop:procedure, prop:match-expander, and contract blame

2015-04-15 Thread Jon Zeppieri
You got it. On Apr 15, 2015, at 10:19 PM, Alexander D. Knauth alexan...@knauth.org wrote: On Apr 15, 2015, at 10:12 PM, Jon Zeppieri zeppi...@gmail.com wrote: On Wed, Apr 15, 2015 at 9:35 PM, Alexander D. Knauth alexan...@knauth.org wrote: On Apr 15, 2015, at 2:29 PM, Jon Zeppieri

Re: [racket-users] prop:procedure, prop:match-expander, and contract blame

2015-04-15 Thread Jon Zeppieri
On Wed, Apr 15, 2015 at 9:35 PM, Alexander D. Knauth alexan...@knauth.org wrote: On Apr 15, 2015, at 2:29 PM, Jon Zeppieri zeppi...@gmail.com wrote: I'm trying to provide a struct, the struct type of which uses prop:procedure and prop:match-expander, and I'd like the procedure to have

Re: [racket-users] DrRacket plugin to remove trailing whitespace on save?

2015-04-13 Thread Jon Zeppieri
So, just to be clear, because there have been a number of +1s for a whitespace-highlighting feature: that's not what I'm doing. A bunch of people want that, so someone should write it, but I'm not going in that direction. (In fact, one of my emacs configurations does this in ruby-mode, and I keep

Re: [racket-users] DrRacket plugin to remove trailing whitespace on save?

2015-04-13 Thread Jon Zeppieri
On Mon, Apr 13, 2015 at 1:06 PM, John Clements cleme...@brinckerhoff.org wrote: On Apr 13, 2015, at 2:29 AM, Jon Zeppieri zeppi...@gmail.com wrote: It's supposed to have the same effect as emacs's `delete-trailing-whitespace`. I still need to add a preference setting to turn it on or off

Re: [racket-users] DrRacket plugin to remove trailing whitespace on save?

2015-04-13 Thread Jon Zeppieri
On Mon, Apr 13, 2015 at 1:27 PM, Robby Findler ro...@eecs.northwestern.edu wrote: Preferences are here for the prefs library: http://docs.racket-lang.org/framework/Preferences__Textual.html and here for adding check boxes to the prefs dialog:

Re: [racket-users] DrRacket plugin to remove trailing whitespace on save?

2015-04-13 Thread Jon Zeppieri
endings and then delete stuff and ace the file again. Robby On Sunday, April 12, 2015, Jon Zeppieri zeppi...@gmail.com wrote: Does such a think already exist? -Jon -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group

Re: [racket-users] DrRacket plugin to remove trailing whitespace on save?

2015-04-12 Thread Jon Zeppieri
whitespace added going forward. Writing a script to trim whitespace from line-endings would work well if it were to use text% IMO. Use load-file to get a file and then the paragraph methods to find line endings and then delete stuff and ace the file again. Robby On Sunday, April 12, 2015, Jon

[racket-users] DrRacket plugin to remove trailing whitespace on save?

2015-04-12 Thread Jon Zeppieri
Does such a think already exist? -Jon -- 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

Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
On Thu, Mar 26, 2015 at 3:56 PM, John Clements cleme...@brinckerhoff.org wrote: On Mar 25, 2015, at 6:55 PM, Jon Zeppieri zeppi...@gmail.com wrote: I recently uploaded Gregor, a date and time library, to the package server. Can I use this instead of SRFI 19? That would be wonderful. John

Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
On Thu, Mar 26, 2015 at 4:57 PM, Vincent St-Amour stamo...@ccs.neu.edu wrote: At Thu, 26 Mar 2015 14:30:28 -0400, Jon Zeppieri wrote: [ snip] Since, IIUC, periods need to be anchored to a specific point in time, that would make them a bit more heavyweight to create. I could see durations

Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
On Thu, Mar 26, 2015 at 5:27 PM, Robby Findler ro...@eecs.northwestern.edu wrote: On Thu, Mar 26, 2015 at 4:13 PM, Jon Zeppieri zeppi...@gmail.com wrote: You can carry around a bucket that says 5 years, 3 weeks, and 40 hours, but the precise number of seconds inside the bucket is indeterminate

Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
, 2015, at 5:41 PM, Jens Axel Søgaard jensa...@soegaard.net wrote: 2015-03-26 22:30 GMT+01:00 Jon Zeppieri zeppi...@gmail.com: On Thu, Mar 26, 2015 at 5:27 PM, Robby Findler Would 3 weeks and 40 hours always be a precise number of seconds? Robby What about leap seconds? /Jens Axel

Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
not be of general interest, we could move it over to gregor's github site and use the issue tracker. Most of all, thank you for your interest. -Jon At Wed, 25 Mar 2015 21:55:31 -0400, Jon Zeppieri wrote: I recently uploaded Gregor, a date and time library, to the package server. Features

Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
approach probably helps with both problems. On Thu, Mar 26, 2015 at 6:43 PM, Sam Tobin-Hochstadt sa...@cs.indiana.edu wrote: On Thu, Mar 26, 2015 at 4:26 PM Jon Zeppieri zeppi...@gmail.com wrote: On Thu, Mar 26, 2015 at 3:56 PM, John Clements cleme...@brinckerhoff.org wrote: On Mar 25

Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
On Thu, Mar 26, 2015 at 5:30 PM, Jon Zeppieri zeppi...@gmail.com wrote: 3 weeks and 40 hours will always have a fixed number of seconds... And this is because Gregor isn't faithful to UTC, of course. Otherwise, this wouldn't be true. -- You received this message because you are subscribed

Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
On Thu, Mar 26, 2015 at 5:27 PM, Robby Findler ro...@eecs.northwestern.edu wrote: On Thu, Mar 26, 2015 at 4:13 PM, Jon Zeppieri zeppi...@gmail.com wrote: You can carry around a bucket that says 5 years, 3 weeks, and 40 hours, but the precise number of seconds inside the bucket is indeterminate

Re: [racket-users] ANN: Gregor, a date and time library

2015-03-26 Thread Jon Zeppieri
not be of general interest, we could move it over to gregor's github site and use the issue tracker. Most of all, thank you for your interest. -Jon At Wed, 25 Mar 2015 21:55:31 -0400, Jon Zeppieri wrote: I recently uploaded Gregor, a date and time library, to the package server. Features

<    1   2   3