Re: [racket-users] Decision Tree in Racket - Performance

2017-07-23 Thread Jon Zeppieri
On Sun, Jul 23, 2017 at 8:43 PM, David Storrs <david.sto...@gmail.com> wrote: > > > On Sun, Jul 23, 2017 at 8:05 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: >> - Use a struct instead of a hash to represent a split. > > > Oh, are structs faster than has

Re: [racket-users] Decision Tree in Racket - Performance

2017-07-23 Thread Jon Zeppieri
On Sun, Jul 23, 2017 at 7:30 PM, Zelphir Kaltstahl wrote: > Hi Racket Users, > > The last few days I've been working on implementing decision trees in Racket > and I've been following the following guide: >

Re: [racket-users] IO in racket is painful

2017-07-22 Thread Jon Zeppieri
On Sat, Jul 22, 2017 at 3:30 PM, David Storrs wrote: > > Alternatively, if 'match' made the results of a successful regexp test > available to the bodies on the RHS then you could do the same thing by > accessing the result list. Perhaps if match would allow the RHS to be

Re: [racket-users] for/list with in-parallel lists

2017-07-10 Thread Jon Zeppieri
On Tue, Jul 11, 2017 at 12:56 AM, Alex Knauth wrote: > > You can do this with the Generic Bind package [1]. Oh, this is very nice. Thank you. -J -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this

Re: [racket-users] for/list with in-parallel lists

2017-07-10 Thread Jon Zeppieri
On Tue, Jul 11, 2017 at 12:28 AM, Jon Zeppieri <zeppi...@gmail.com> wrote: > > As far as I know, there's nothing built-in that does this, but it's > not hard to build: > ... though a syntactic solution combining for and match would probably be better. -- You received this m

Re: [racket-users] for/list with in-parallel lists

2017-07-10 Thread Jon Zeppieri
On Tue, Jul 11, 2017 at 12:16 AM, Nadeem Abdul Hamid wrote: > I'm looking for a general solution. Basically, I thought binding multiple > id's would have achieved what this does: > >> (for/list ([t '((1 2 3) (4 5 6) (7 8 9) (a b c))]) > (match-define (list x y z) t) >

Re: [racket-users] for/list with in-parallel lists

2017-07-10 Thread Jon Zeppieri
On Mon, Jul 10, 2017 at 11:40 PM, Nadeem Abdul Hamid wrote: > Given a list of pairs, I'm trying to iterate through the list and bind the > first and second elements of each pair to x and y, respectively, in each > iteration. > > For example, hash sets are a multiple-valued

Re: [racket-users] for/list with in-parallel lists

2017-07-10 Thread Jon Zeppieri
On Mon, Jul 10, 2017 at 11:02 PM, Nadeem Abdul Hamid wrote: > How come this: >(for/list ([(x y) (in-parallel '(1 2) '(3 4))]) x) > produces > '(1 2) > instead of > '(1 3) > ? You're creating a list of the x values. In the first iteration x is 1, and in the second it's 2.

Re: [racket-users] Code critique (of naive code) would be very appreciated

2017-06-21 Thread Jon Zeppieri
And I should heed my own advice about testing. On Wed, Jun 21, 2017 at 8:40 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: > > #lang at-exp racket > > (define (normalize-keywords in) > (regexp-replace* >@pregexp|{Keywords ?= ?\{\s*([^}]*)\}}| >in >

Re: [racket-users] Code critique (of naive code) would be very appreciated

2017-06-21 Thread Jon Zeppieri
On Wed, Jun 21, 2017 at 8:40 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: > > #lang at-exp racket > > ;; normalize-keywords: string? -> string? > #lang at-exp racket > Sorry, I made some bad edits here. Should have been: #lang at-exp racket ;; normalize-keywords:

Re: [racket-users] Code critique (of naive code) would be very appreciated

2017-06-21 Thread Jon Zeppieri
Hi Glenn, This is pretty good! I added some remarks below: On Wed, Jun 21, 2017 at 3:48 PM, Glenn Hoetker wrote: > > ;;; > #lang racket > > (define in (open-input-file "/Users/me/BibDeskPapers/oldBib.bib")) > (define

Re: [racket-users] Naive question on how to capitalize only the first word of a string

2017-06-19 Thread Jon Zeppieri
On Mon, Jun 19, 2017 at 8:12 PM, Glenn Hoetker wrote: > I'm quite new to Racket/LISP, so I hope this isn't breathtakingly obvious. > Can someone please tell me the best way to capitalize just the first word in > a multiword string. So, given the string "it was a dark and

Re: [racket-users] Making change in Racket / lazy language question

2017-06-16 Thread Jon Zeppieri
On Fri, Jun 16, 2017 at 5:41 PM, Daniel Prager wrote: > > But I get a perplexing error if I try to use foldl for added elegance when > defining twos: > > (define (cc x . xs) (foldl sadd (fcoin x) xs)) > (define twos (cc 1 2 5 10 20 50 100 200)) > > take: expects type

Re: [racket-users] Data contract for non-empty hash?

2017-06-12 Thread Jon Zeppieri
Predicates can be used as contracts, so: (define (non-empty-hash? x) (and (hash? x) (not (hash-empty? x Then you can use `non-empty-hash?` as your contract. On Mon, Jun 12, 2017 at 3:56 PM, David Storrs wrote: > There is a non-empty-listof contract but no

Re: [racket-users] Performance of the Racket reader

2017-06-01 Thread Jon Zeppieri
On Thu, Jun 1, 2017 at 11:07 AM, Jon Zeppieri <zeppi...@gmail.com> wrote: > > >> On Jun 1, 2017, at 10:52 AM, Steve Byan's Lists <steve-l...@byan-roper.org> >> wrote: >> >> Hi Jon, >> >>>> On May 31, 2017, at 6:41 PM, Steve Byan's Lists

Re: [racket-users] Performance of the Racket reader

2017-06-01 Thread Jon Zeppieri
> On Jun 1, 2017, at 10:52 AM, Steve Byan's Lists <steve-l...@byan-roper.org> > wrote: > > Hi Jon, > >>> On May 31, 2017, at 6:41 PM, Steve Byan's Lists <steve-l...@byan-roper.org> >>> wrote: >>> >>> On May 31, 2017, a

Re: [racket-users] Performance of the Racket reader

2017-05-31 Thread Jon Zeppieri
On Wed, May 31, 2017 at 10:05 PM, Steve Byan's Lists wrote: > > I did consider using an association list representation for the attributes, > but I'm depending on s-expression pattern matching for parsing the records. > It's wonderfully convenient for this. I'm under

Re: [racket-users] Performance of the Racket reader

2017-05-31 Thread Jon Zeppieri
On Wed, May 31, 2017 at 5:54 PM, Steve Byan's Lists wrote: > Hi Mathias, > > Thanks for taking a look. > >> On May 31, 2017, at 4:13 PM, Matthias Felleisen wrote: >> >> >> Can you explain why you create a lazy stream instead of a plain list? > >

Re: [racket-users] Html to text, how to obtain a rough preview

2017-05-30 Thread Jon Zeppieri
((sxpath '(// *text*)) doc) should return all (and only) the text nodes in doc. I'm not so familiar with the sxml-xexp compatibility stuff, so I don't know if you can use an xexp here or if you really need an sxml document. On Tue, May 30, 2017 at 7:08 AM, Erich Rast wrote: > Hi

Re: [racket-users] immutable hash table performance

2017-05-25 Thread Jon Zeppieri
On Thu, May 25, 2017 at 6:16 PM, 'John Clements' via Racket Users wrote: > Following up on a discussion I had with another teacher here, I decided to > briefly investigate the running time of insertion and deletion on mutable vs > immutable hash tables. I was a

Re: [racket-users] Re: Proper non-tail recursion?

2017-04-27 Thread Jon Zeppieri
On Thu, Apr 27, 2017 at 8:13 PM, Justin Zamora <jus...@zamora.com> wrote: > On Thu, Apr 27, 2017 at 8:06 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: >> >> OCaml does handle tail calls properly. But proper tails calls are not >> the subject of this discussion.

Re: [racket-users] Re: Proper non-tail recursion?

2017-04-27 Thread Jon Zeppieri
On Thu, Apr 27, 2017 at 8:05 PM, Hendrik Boom <hend...@topoi.pooq.com> wrote: > On Thu, Apr 27, 2017 at 07:14:15PM -0400, Jon Zeppieri wrote: >> On Thu, Apr 27, 2017 at 7:10 PM, Raoul Duke <rao...@gmail.com> wrote: >> > i should think any "real" fp wou

Re: [racket-users] Re: Proper non-tail recursion?

2017-04-27 Thread Jon Zeppieri
On Thu, Apr 27, 2017 at 7:10 PM, Raoul Duke wrote: > i should think any "real" fp would support it. where real is a bijection > with having such support. well, at least necessary if not sufficient. That would be a rather contentious claim, as it rules out OCaml, for example.

Re: [racket-users] Best way to write run-once-and-cache functions?

2017-04-26 Thread Jon Zeppieri
On Wed, Apr 26, 2017 at 12:48 PM, David Storrs <david.sto...@gmail.com> wrote: > > > On Wed, Apr 26, 2017 at 12:21 AM, Jon Zeppieri <zeppi...@gmail.com> wrote: >> >> I don't know that there's a right way, but if your functions are >> nullary, then promis

Re: [racket-users] Best way to write run-once-and-cache functions?

2017-04-25 Thread Jon Zeppieri
I don't know that there's a right way, but if your functions are nullary, then promises are a decent fit: (define conf (delay (with-input-from-file ...))) Then just (force conf) whenever you want the value. On Wed, Apr 26, 2017 at 12:12 AM, David Storrs wrote: >

Re: [racket-users] Proper non-tail recursion?

2017-04-25 Thread Jon Zeppieri
On Tue, Apr 25, 2017 at 6:37 PM, brendan wrote: > Scheme implementations are required to have proper tail recursion. Racket > goes further and lets the programmer make recursive calls from any position > without fear because, to paraphrase Dr. Flatt, it's the 21st century

Re: [racket-users] Reporting exceptions as though they came from the caller

2017-03-31 Thread Jon Zeppieri
On Fri, Mar 31, 2017 at 4:00 PM, David Storrs wrote: > Imagine I have the following trivial module (ignore that things are defined > out of sequence for clarity): > > #lang racket > > (define (foo arg) > (_baz arg) ; do some checking, raise an exception if there's a

Re: [racket-users] how to `read-char` from port using `latin-1` encoding?

2017-03-31 Thread Jon Zeppieri
Try using "iso-8859-1" as the name of the encoding, instead of "latin-1." -J On Fri, Mar 31, 2017 at 3:55 PM, Matthew Butterick wrote: > IIUC when `read-char` reads from a port it assumes the port uses UTF-8 > encoding. [1] > > (My Racketuition suggests there might be a

Re: [racket-users] How to store a list (or struct...) in SQL and extract again as original Racket value

2017-03-21 Thread Jon Zeppieri
Oh, never mind. I see what you mean. On Tue, Mar 21, 2017 at 8:42 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: > Did you try a using a bytea field? > > On Tue, Mar 21, 2017 at 8:36 PM, Marc Kaufmann > <marc.kaufman...@gmail.com> wrote: >> Thanks. But I have to turn i

Re: [racket-users] How to store a list (or struct...) in SQL and extract again as original Racket value

2017-03-21 Thread Jon Zeppieri
On Tue, Mar 21, 2017 at 5:44 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: > However, postgres (if that's what you're using) > has multidimensional arrays as a native type, so you could use those > [https://www.postgresql.org/docs/current/static/arrays.html]. The > Racket db packa

Re: [racket-users] How to store a list (or struct...) in SQL and extract again as original Racket value

2017-03-21 Thread Jon Zeppieri
On Tue, Mar 21, 2017 at 5:34 PM, Marc Kaufmann wrote: > Hi, > > I want to store matrices of the following form (but larger) in a database: > > (define m '((0 1) (1 0))) > > Currently I manage to store them by turning them into strings first via: > > (~a (serialize m));

Re: [racket-users] Why doesn't this maxval function correctly return the maximum value in the list

2017-02-12 Thread Jon Zeppieri
On Sun, Feb 12, 2017 at 3:00 PM, Angus wrote: > I am a beginner Racket developer by the way. > > Here is my maxval function which is supposed to take a list and return the > largest integer in the list. > > (define (maxval lst) >(define (aux lst max) > (cond

Re: [racket-users] Basic macro question

2017-02-05 Thread Jon Zeppieri
On Sun, Feb 5, 2017 at 10:12 PM, wrote: > Ahh... datum->syntax, I thought I had seen something like this before. It is > treating "a", or a's form, as the scope for the new ids essentially, but I > can pick standard names. This just presupposes I only care to use my "a" >

Re: [racket-users] Basic macro question

2017-02-05 Thread Jon Zeppieri
On Sun, Feb 5, 2017 at 9:41 PM, wrote: > I must be missing something simple here. > > 229> (define-syntax a (lambda (stx) (syntax-parse stx [(a) #`(begin (define x > 97) (define y 98) (define z 99))]))) > 230>(a) > 231>y > 232; y:undefined; > 233; cannot reference undefined

Re: [racket-users] Beginners question: implementing existing generics for existing structs

2017-01-31 Thread Jon Zeppieri
On Tue, Jan 31, 2017 at 4:49 PM, Ronie Uliana wrote: > Let's assume I have a struct that is not mine (like ddict > [https://pkgn.racket-lang.org/package/ddict], or some of pfds > [https://pkgn.racket-lang.org/package/pfds]). I'd like to implement generics > for them

Re: [racket-users] Thread and filesystem watching

2017-01-25 Thread Jon Zeppieri
On Wed, Jan 25, 2017 at 8:03 PM, Matthew Flatt wrote: > > The `handle-evt` constructor does that. > > For example, this loop will print "one" or "two" pseudorandomly, depending on > whether the first or second semaphore is chosen: > > (let loop () >(define e1 >

Re: [racket-users] Thread and filesystem watching

2017-01-25 Thread Jon Zeppieri
On Wed, Jan 25, 2017 at 7:34 PM, David Storrs wrote: > > > After trying this out I see there's a problem: if you apply sync to all of > them simultaneously there is no way to distinguish which directory it was > that changed. By spawning a separate thread for each one

Re: [racket-users] Thread and filesystem watching

2017-01-24 Thread Jon Zeppieri
Hi David, On Tue, Jan 24, 2017 at 6:52 PM, David Storrs wrote: > [snip] > > - When I create the 'monitor this' event, I will need to wrap the sync in >> a thread since (sync) is synchronous. > > > > If I understand you correctly, you're considering creating a separate

Re: [racket-users] Client side web applications in Racket

2017-01-22 Thread Jon Zeppieri
> On Jan 22, 2017, at 4:33 PM, Philip McGrath wrote: > > My understanding is that implementation is still lagging, but I believe ES6 > specifies proper tail calls, yes? > > -Philip Yep. Right now (among browsers) I think only Safari ships with it. -J -- You

Re: [racket-users] contracts: the blame name game

2017-01-03 Thread Jon Zeppieri
ssage. > > Also, if you can use a `let`, that's probably better than > procedure-rename, eg: > > (define make-bar > (let ([bar (λ (x [y 1] [z 1]) >(bar x y z))]) > bar)) > > (It won't matter unless you call `bar` a lot.) > > Robby > &

[racket-users] contracts: the blame name game

2017-01-02 Thread Jon Zeppieri
Over time I've run into a number of problems trying to provide custom struct constructors and match expanders under the same name, while also attaching module-level contracts to the constructors. I've figured out most of the issues (I think), but one remains. Here's an example: === #lang

Re: [racket-users] Cleanest way to locate contiguous sequences? (as part of reuniting segments of a file)

2016-12-02 Thread Jon Zeppieri
You could use an interval tree instead of a list. Before inserting into it, you could check to see if your current chunk number is contiguous with an existing interval in the tree. If so, merge the chunks and expand the existing interval. Otherwise, insert an interval of size 1 into the tree.

Re: [racket-users] Very beginner Student who needs Help!

2016-11-27 Thread Jon Zeppieri
Well, okay, first your program needs to admit the possibility of an empty list. But once it does, see my previous message. > On Nov 27, 2016, at 3:45 PM, Ben Ghanem Anis wrote: > > Hey guys, > I need some help .. > I need to write two procedures .. first one should be

Re: [racket-users] Very beginner Student who needs Help!

2016-11-27 Thread Jon Zeppieri
Okay, it might be more obvious how to approach the second procedure if we first consider a missing case in your first. What happens if you try to insert a real into an empty list, using your procedure? > On Nov 27, 2016, at 3:45 PM, Ben Ghanem Anis wrote: > > Hey

Re: [racket-users] find-seconds daylight saving

2016-11-10 Thread Jon Zeppieri
On Thu, Nov 10, 2016 at 10:52 AM, Jon Zeppieri <zeppi...@gmail.com> wrote: > > > On Thu, Nov 10, 2016 at 10:45 AM, Jon Zeppieri <zeppi...@gmail.com> wrote: > >> >> >> On Thu, Nov 10, 2016 at 4:52 AM, George Neuner <gneun...@comcast.net> >>

Re: [racket-users] find-seconds daylight saving

2016-11-10 Thread Jon Zeppieri
On Thu, Nov 10, 2016 at 10:45 AM, Jon Zeppieri <zeppi...@gmail.com> wrote: > > > On Thu, Nov 10, 2016 at 4:52 AM, George Neuner <gneun...@comcast.net> > wrote: > >> >> On 11/9/2016 2:18 AM, Ryan Culpepper wrote: > > > >> >> Postgresq

Re: [racket-users] find-seconds daylight saving

2016-11-10 Thread Jon Zeppieri
On Thu, Nov 10, 2016 at 4:52 AM, George Neuner wrote: > > On 11/9/2016 2:18 AM, Ryan Culpepper wrote: > >> >> Another option is to let PostgreSQL do it for you using AT TIME ZONE (or >> the timezone function): >> >> select ('2016-11-09 01:23:00Z'::timestamptz) >> at

Re: [racket-users] find-seconds daylight saving

2016-11-09 Thread Jon Zeppieri
On Tue, Nov 8, 2016 at 11:24 PM, George Neuner <gneun...@comcast.net> wrote: > Hi Jon, > > On 11/8/2016 6:28 PM, Jon Zeppieri wrote: > > > George, these are not correct results. The UTC offset is correct, but the >> time fields are not -- under the assumption that

Re: [racket-users] find-seconds daylight saving

2016-11-08 Thread Jon Zeppieri
On Tue, Nov 8, 2016 at 6:26 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: > > > On Tue, Nov 8, 2016 at 6:18 PM, George Neuner <gneun...@comcast.net> > wrote: > >> >> On 11/8/2016 2:29 PM, Robby Findler wrote: >> >>> find-seconds returns a numb

Re: [racket-users] find-seconds daylight saving

2016-11-08 Thread Jon Zeppieri
On Tue, Nov 8, 2016 at 6:18 PM, George Neuner wrote: > > On 11/8/2016 2:29 PM, Robby Findler wrote: > >> find-seconds returns a number, not a date? Maybe seconds->date is the >> culprit here? >> >> Robby >> > > Spoke too soon. 1 combination gets it right: (seconds->date >

Re: [racket-users] find-seconds daylight saving

2016-11-08 Thread Jon Zeppieri
I think Robby is right and the problem is here: https://github.com/racket/racket/blob/4ce947da74d09abc9cda10a14e7407cda9386a44/racket/src/racket/src/fun.c#L9876 Well, that and the next line. There's only a `return 1;` for the case where the given day-of-month is less than the DST change's

Re: [racket-users] Recursive stepping down a list patially?

2016-10-31 Thread Jon Zeppieri
On Mon, Oct 31, 2016 at 11:28 PM, wrote: > > Hi Jon, > > thanks for reply! :) > > My plan was, to return only one element from that list and > possibly some extra informations and pass that to the processing > function so it could right jump onto that train... > > Is that

Re: [racket-users] Recursive stepping down a list patially?

2016-10-31 Thread Jon Zeppieri
On Mon, Oct 31, 2016 at 10:53 PM, wrote: > Hi, > > I have a lng list of something. And I have a recursive serach > function to crawl down the list and search for a previously determined > item. > When found, the search processes stops and returns that item of the > list.

[racket-users] Convention for package build scripts (that don't really have to be part of the package)?

2016-10-28 Thread Jon Zeppieri
When I made recent changes to my tzdata package, I included a module that automates the process of re-building the package. (It downloads the latest version of the tz data and its associated code, builds the zoneinfo database from it, and constructs an info.rkt file for it.) I have a similar kind

Re: [racket-users] Structs vs Lists

2016-10-27 Thread Jon Zeppieri
On Thu, Oct 27, 2016 at 1:09 PM, Ken MacKenzie wrote: > Thank you that makes sense. Vectors are fixed length so in theory could I > also say a Vector is possibly more performant than an equivalent list? > > Ken > For accessing an arbitrary member, yes. A Racket vector is

Re: [racket-users] Structs vs Lists

2016-10-27 Thread Jon Zeppieri
On Thu, Oct 27, 2016 at 12:16 PM, Ken MacKenzie wrote: > This is a question more about the footprint of each. Deep down is a > Struct really just syntactic sugar over a list. Not in Racket (or in most Lisps these days). > As in most things in Lisp from my

Re: [racket-users] Unable to track down what is requiring inclusion of tzinfo module - Resolved

2016-10-22 Thread Jon Zeppieri
the time, can you confirm that this works for you? (Of course, if you're not on Windows, you won't need the tzdata package, but the previous way that the code tried to use it would break with `raco exe` regardless of what system you use.) - Jon On Fri, Oct 21, 2016 at 3:50 PM, Jon Zeppieri <ze

Re: [racket-users] Unable to track down what is requiring inclusion of tzinfo module - Resolved

2016-10-21 Thread Jon Zeppieri
This connects to a similar issue I was having with my reorganization of the CLDR libraries (which I'm getting back into): https://groups.google. com/d/msg/racket-dev/MrmxvvKidj8/ASEF22_lBQAJ. It looks like, in the present case, I should do something like this: - The tzdata package includes, in

Re: [racket-users] Re: date->seconds complaining about a supposedly non-existent date

2016-10-21 Thread Jon Zeppieri
On Fri, Oct 21, 2016 at 12:17 AM, Jack Firth wrote: > There's also the Gregor package (https://docs.racket-lang.org/ > gregor/index.html?q=gregor), which gives a much more comprehensive > interface to dates and times. In particular, Gregor allows you to specify > an "offset

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:

Re: [racket-users] Constructing unicode surrogates

2016-10-08 Thread Jon Zeppieri
On Sat, Oct 8, 2016 at 1:06 PM, Jens Axel Søgaard wrote: > Hi All, > > The following interaction shows how the reader can be used to construct a > surrogate character: > > > (string-ref "\ud800\udc00" 0) > #\ > > Given the two hexadecimal numbers d800 and dc00 how

Re: [racket-users] Using schemas with the 'db' module

2016-10-06 Thread Jon Zeppieri
;. See > > https://www.postgresql.org/docs/current/static/ddl-schemas.html > https://www.postgresql.org/docs/current/static/sql-set.html > > Ryan > >> On 10/06/2016 06:21 PM, Jon Zeppieri wrote: >> Isn't the #:database parameter in postgresql-connect what you're

Re: [racket-users] Using schemas with the 'db' module

2016-10-06 Thread Jon Zeppieri
Isn't the #:database parameter in postgresql-connect what you're looking for? > On Oct 6, 2016, at 6:12 PM, David Storrs wrote: > > Is it possible to connect to a specific schema in a Postgres database, or to > set the current schema of an existing connection? > >

Re: [racket-users] sequence of moments?

2016-09-22 Thread Jon Zeppieri
> On Sep 22, 2016, at 3:57 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: > > > >>> On Sep 22, 2016, at 3:43 PM, Geoffrey Knauth <ge...@knauth.org> wrote: >>> >>> On Thursday, September 22, 2016 at 3:17:50 PM UTC-4, Jon Zeppieri wrote: >&g

Re: [racket-users] sequence of moments?

2016-09-22 Thread Jon Zeppieri
> On Sep 22, 2016, at 3:43 PM, Geoffrey Knauth <ge...@knauth.org> wrote: > >> On Thursday, September 22, 2016 at 3:17:50 PM UTC-4, Jon Zeppieri wrote: >> Oh, sorry: I thought you wanted a sequence of moments from start and end >> *seconds*. If you're startin

Re: [racket-users] sequence of moments?

2016-09-22 Thread Jon Zeppieri
> On Sep 22, 2016, at 3:12 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: > > > >> On Sep 22, 2016, at 2:04 PM, Geoffrey Knauth <ge...@knauth.org> wrote: >> >> Is it possible to build a sequence of moments? (require gregor) >>

Re: [racket-users] sequence of moments?

2016-09-22 Thread Jon Zeppieri
> On Sep 22, 2016, at 2:04 PM, Geoffrey Knauth wrote: > > Is it possible to build a sequence of moments? (require gregor) > > I had a sequence of seconds (since the epoch), as in: > > (in-range start-seconds end-seconds seconds-in-a-day) > > If I use moments, I'm

Re: [racket-users] Persisting large values for debugging long-running programs

2016-09-14 Thread Jon Zeppieri
> On Sep 14, 2016, at 4:24 PM, 'John Clements' via Racket Users > wrote: > > Just in case this information is useful: > > The “classical” hack here—Eli showed me this, I believe—is to write the data > out in the form of a file that “provide”s the specified

Re: [racket-users] Persisting large values for debugging long-running programs

2016-09-14 Thread Jon Zeppieri
'Course you already mentioned a custom encoding, so, yeah, fasl: https://docs.racket-lang.org/reference/fasl.html > On Sep 14, 2016, at 3:47 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: > > I think reading and writing fasl should be faster, but don't expect the > format to be

Re: [racket-users] Persisting large values for debugging long-running programs

2016-09-14 Thread Jon Zeppieri
I think reading and writing fasl should be faster, but don't expect the format to be compatible across Racket versions. Or, if you know some super-efficient encoding for your data, wrap it in a new struct type and implement your own serialization. > On Sep 14, 2016, at 3:38 PM, Jonathan

Re: [racket-users] Re: lambda and the equivalent define / "defun"

2016-09-07 Thread Jon Zeppieri
On Wed, Sep 7, 2016 at 12:18 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: > > Note that this function still generates a list as output. I suppose it > could instead generate as many values as there are initial elements of xs, > Uh, and you can disregard this statement alto

Re: [racket-users] Re: lambda and the equivalent define / "defun"

2016-09-07 Thread Jon Zeppieri
On Wed, Sep 7, 2016 at 12:18 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: > > > ``` > #lang racket/base > > (require racket/match) > > (define (foldl* proc init . xs) > (match xs > ['() init] > [(cons x xs) (apply foldl* proc (proc x init) xs)])

Re: [racket-users] Re: lambda and the equivalent define / "defun"

2016-09-07 Thread Jon Zeppieri
On Wed, Sep 7, 2016 at 11:54 AM, Sanjeev Sharma wrote: > Just illustrates the changing structure (increased nesting depth) on each > recursive call > > The initial call to t2 changes the structure of the > argument/parameter - it puts in a list where there was no list. > >

Re: [racket-users] Re: lambda and the equivalent define / "defun"

2016-09-07 Thread Jon Zeppieri
On Wed, Sep 7, 2016 at 8:33 AM, Sanjeev Sharma wrote: > Thanks for joining in. > > The amended question had nothing to do with the earlier example > Okay. > > I'm wondering if there's a quick, standard (and easily understood) idiom > (without an internal helper function)

Re: [racket-users] Re: lambda and the equivalent define / "defun"

2016-09-06 Thread Jon Zeppieri
On Tue, Sep 6, 2016 at 8:50 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: > > > > The `(lambda s ...)` is variable-arity, but when you call `ss` internally > [...] > Sorry, I realized after that your `ss` function essentially *is* a wrapper around your `subsets` function --

Re: [racket-users] Re: lambda and the equivalent define / "defun"

2016-09-06 Thread Jon Zeppieri
On Tue, Sep 6, 2016 at 7:30 PM, Sanjeev Sharma wrote: > Thanks, that's helpful > > I am having trouble coming up with a quick and easy shorthand to recur on > the rest parameter - is there a standard way to cdr down this list without > an intermediary helper function that

Re: [racket-users] equivalence relation for hash keys

2016-08-04 Thread Jon Zeppieri
On Thu, Aug 4, 2016 at 12:34 PM, Jos Koot wrote: > Hi > > As far as I can see a hash has three options only for the equivalence > relation comparing keys: eq?, eqv? and equal?. > Would it be possible to extend Racket such as to allow the preparation of > hashes with a user

Re: [racket-users] `eqv?` vs `eq?` for interned numbers & characters

2016-07-24 Thread Jon Zeppieri
On Mon, Jul 25, 2016 at 12:35 AM, Matthew Butterick wrote: > The docs say `eqv?` differs from `eq?` only for nmbers and characters. But > is this still true since numbers and characters became interned data types > in 2011? [1] > That mail thread is specifically about *literal*

Re: [racket-users] Is my model of (values) accurate?

2016-07-22 Thread Jon Zeppieri
On Fri, Jul 22, 2016 at 7:58 PM, David Storrs wrote: > Thanks Jon, I appreciate the clear explanation. > > I'm using call-with-values in database code in order to turn a list into > an acceptable set of bind parameters. Here's an example: > > (query-exec conn "insert

Re: [racket-users] Is my model of (values) accurate?

2016-07-22 Thread Jon Zeppieri
On Fri, Jul 22, 2016 at 6:30 PM, David Storrs wrote: > > The best mental model I've been able to come up with is that (values) > returns its results vertically but most functions expect to get them > horizontally and will die if there are parallel lines of uncollected >

[racket-users] Re: How to differentiate between files and directories?

2016-07-21 Thread Jon Zeppieri
On Thu, Jul 21, 2016 at 3:59 PM, David Storrs wrote: > So there's no way to query the interface of a struct? > > > Not in general, no. -J -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group

Re: [racket-users] How to differentiate between files and directories?

2016-07-21 Thread Jon Zeppieri
On Thu, Jul 21, 2016 at 2:44 PM, David Storrs wrote: > > > > In a related question, is there a way to introspect a struct to find > out what its fields are? > > If you mean the field values: yes, but only if the struct is transparent or prefab or if you have the proper

Re: [racket-users] How to differentiate between files and directories?

2016-07-21 Thread Jon Zeppieri
On Thu, Jul 21, 2016 at 2:44 PM, David Storrs wrote: > > > I saw 'file-exists?' but I don't want to check the disk twice, I just > want to know what type it is. That information should have been > available when the path was constructed. > > Constructing a path doesn't

Re: [racket-users] provide/contract with an id that doubles as a match expander

2016-06-09 Thread Jon Zeppieri
On Thu, Jun 9, 2016 at 2:24 PM, Alex Knauth wrote: > > > There's `define-module-boundary-contract`, which does something similar to > `define/contract` except that it uses the module as a boundary instead of > creating it's own: > >

[racket-users] provide/contract with an id that doubles as a match expander

2016-06-09 Thread Jon Zeppieri
I think I've asked a question like this in the past, but I still haven't found a good solution. I'm going to give a concrete example: Let's say I have a `date` struct like this: (struct date (y m d)) And I'm perfectly happy with the default match expander: (match d [(date y m d) ...]) But

Re: [racket-users] Case vs. Match

2016-06-03 Thread Jon Zeppieri
There's rarely a good reason. If you were dispatching over a very large set of constants -- fixnums or characters, in particular -- I'd expect better performance from case. That's about it. > On Jun 3, 2016, at 10:10 AM, Gerald Pipes > wrote: > > I have been

Re: [racket-users] File Ports / Writing to a file

2016-04-20 Thread Jon Zeppieri
On Wed, Apr 20, 2016 at 5:03 PM, George Mitwasi <mitwasi.geo...@gmail.com> wrote: > On Wednesday, April 20, 2016 at 3:09:53 PM UTC-4, Jon Zeppieri wrote: > > Maybe you're using one of the teaching languages instead of Racket > proper? In the "Language" menu, if

Re: [racket-users] File Ports / Writing to a file

2016-04-20 Thread Jon Zeppieri
Maybe you're using one of the teaching languages instead of Racket proper? In the "Language" menu, if you select "Choose Language..." you'll see a dialog. It should tell you what language you're using. -Jon On Wed, Apr 20, 2016 at 3:05 PM, George Mitwasi wrote: >

Re: [racket-users] Case and eof

2016-04-04 Thread Jon Zeppieri
On Mon, Apr 4, 2016 at 3:40 PM, Jay McCarthy wrote: > case is just for integers and symbols. > I'm not sure if you meant this as a claim about how you think `case` should be used, but it certainly does work for more than just integers and symbols. It will work for any

Re: [racket-users] Include link in email: what headers to use?

2016-03-27 Thread Jon Zeppieri
On Sun, Mar 27, 2016 at 9:29 AM, Marc Kaufmann wrote: > Ah, of course "extra-header ... " means there can be several of them - > which I know, but forgot in this context. On the other hand, I also didn't > realize that "Conten-Type: text/html; charset=iso-8859-1" was a

Re: [racket-users] Include link in email: what headers to use?

2016-03-26 Thread Jon Zeppieri
The `extra-header` parameter is a rest parameter, so you're supposed to pass one string per header, not a single string containing all of them. And, if you were going to send them all in a single string, you'd need to separate them with an \r\n sequence, not with semicolons. So pass two separate

[racket-users] custom input ports

2016-03-14 Thread Jon Zeppieri
Almost every time I've created a custom input port, I've run up against the rule: "The read-in procedure must not block indefinitely." And each time, I've either: - ignored it (with the suspicion that I've just written code that can block the whole process, though I've never actually verified

[racket-users] ports, custodians, and places

2016-03-12 Thread Jon Zeppieri
I have TCP ports that I send from one place to another. I'd like the receiving place to be responsible for closing them. In particular, I'd like to make that the responsibility of a custodian in the receiving place. If I close the ports in the receiving place, however, that doesn't actually close

Re: [racket-users] Help writing a simple lexer/tokenizer

2016-02-22 Thread Jon Zeppieri
On Mon, Feb 22, 2016 at 7:26 PM, Neil Van Dyke wrote: > For someone who really wants to learn this well, rather than just make a > lexer and move on... > > I started learning the pertinent theory (such as automata NFA/DFA, and > classes of formal languages) from the

Re: [racket-users] Help writing a simple lexer/tokenizer

2016-02-22 Thread Jon Zeppieri
Have you looked at the parser-tools/lex library? https://docs.racket-lang.org/parser-tools/Lexers.html > On Feb 22, 2016, at 4:46 PM, Federico Ramírez wrote: > > Hello everyone! I'm new to Scheme, and I need some help wrapping my head > around it. > > I want to write a

Re: [racket-users] second->date

2016-02-19 Thread Jon Zeppieri
he additional flag to seconds->date: > (seconds->date (sub1 (expt 2 50)) #f) (date* 3 57 18 25 9 35680317 2 267 #f 0 0 "UTC") ... the results are the same. -Jon > > > -- > *From:* Jon Zeppieri [mailto:zeppi...@gmail.com] > *Sent

Re: [racket-users] second->date

2016-02-19 Thread Jon Zeppieri
Er, no. Disregard that. That'll teach me to talk about the Windows API when I know nothing about it. Apparently, the FILETIME type is divided into two 32-bit values. At any rate, there is a bug, but I don't know where it is. -Jon On Fri, Feb 19, 2016 at 5:31 PM, Jon Zeppieri <ze

Re: [racket-users] second->date

2016-02-19 Thread Jon Zeppieri
I'm not especially familiar with the code in question, but it looks to me like some time-handling code in fun.c assumes 32-bit values. I'm referring to this: [ https://github.com/racket/racket/blob/50db01bf2c7c57fd5c7c662307d517ce2c29c279/racket/src/racket/src/fun.c#L9981 ]. On a 64-bit system,

Re: [racket-users] assoc api

2016-02-10 Thread Jon Zeppieri
On Wed, Feb 10, 2016 at 11:02 AM, Neil Van Dyke wrote: > For your example, more traditional would be `(map cons` and `cdr`. Then > it's more clear that `assoc` returning the matched pair lets you > distinguish a `#f` `cdr` in a match from no match found. > > And dict-ref

Re: [racket-users] assoc api

2016-02-10 Thread Jon Zeppieri
I don't know whether there's an advantage or not, but I can say that the behavior of assoc is inherited from Scheme and other Lisps. I usually want the behavior you describe, so I often use dict-ref with dealing with association lists. -Jon On Wed, Feb 10, 2016 at 10:55 AM, Brian Adkins

<    1   2   3   >