[racket-users] ANN: Gregor, a date and time library
I recently uploaded Gregor, a date and time library, to the package server. Features: - representations for and generic operations on: - dates - times (as in, time-of-day) - datetimes (combined date and time) - moments (combined datetime and IANA/Olson timezone) - date arithmetic - localized formatting and parsing, using CLDR data As you might expect from the name, Gregor uses a (proleptic) Gregorian calendar. Documentation: http://pkg-build.racket-lang.org/doc/gregor/index.html Source and bug tracking: https://github.com/97jaz/gregor -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 https://groups.google.com/d/optout.
[racket-users] Custom repl UI widgets
Hey all, I'd like to make some custom interactive UI elements that are similar to the manipulate functionality that mathematica has. I know dr racket already has some elements that display custom in the repl and can be interacted with. Images are displayed, and plots are displayed and interactive. I would like to work on making some more little custom widgets. I worked out from some chatting on irc that snip% is the element that drracket displays. I've looked at the plot snip%, the number snip%, the pict3d snip% and the docs on snip% but I haven't been able to put together a working snip subclass of my own that will display anything. I was wondering if anybody could show me an example of a very simple snip% that maybe drew a circle and had some sort of click interaction that I could work off of. I'm not too familiar with racket's gui system yet so looking for a little sample I can start from. Any help would be great, 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] accumulators vs foldl? was: Fwd: Rsound question
On 3/25/2015 2:07 PM, 'John Clements' via users-redirect wrote: This is a pedagogic question. The discussion below (forwarded with permission) is basically about the best way to find the maximum value in a vector of length four million, a.k.a. a sound file. Non-tail recursion is problematic; I blow a 512M-limited evaluator in about 14 seconds without finding the answer, where tail-calling gets me the answer in about 2 seconds. I have to ask ... how exactly did you search a vector non-tail recursively? So! Here’s the question. Is it better to give students an “rs-foldl” that performs a fold over sound, or to show them accumulator-style programming? I was a bit surprised to see that in HtDP 2e, foldl (a.k.a. “Programming to an Abstraction”) appears much earlier (section 18.4) than accumulator-style (section 35). I suppose this could be because using an abstraction can be easier than devising it, although in the case of (say) map, the book takes care to ensure that students can implement map-like functions in their sleep before showing them the abstraction. Opinions appreciated! That's tough. On one hand, teaching map and fold shows the proper (IMO) way to *think* about the problem - loops are implementation detail. On the other hand, regarding map and fold as black boxes does not give the student any appreciation of their complexity. It's very much like the loop vs recursion argument: unless you have fought with a loop + auxiliary stack implementation, you don't appreciate what recursion is doing for you automagically, nor do you really appreciate its hidden management costs. Having learned loops first [because Lisp was, IIRC, my 5th programming language] I can only speculate on the reverse. I can say that it was easy to understand map and fold [reduce in Lisp] in terms of loops and accumulators, but I think that lacking that perspective it would be possible for a student to compartmentalize and disassociate them. There's also the possibility of mistaking implementation for general concept: e.g., people learning "don't use right fold because it takes O(n) space" ... when _we_ know that is due to an implementation detail and not a failing of right fold in general. I know none of this answers your question. George -- 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] apply: pass keywords to function?
That just reminded me of this, although I think your approach with a separate list for positional arguments might be better: http://pkg-build.racket-lang.org/doc/hash-lambda-toc/hash-lambda_scrbl.html#%28def._%28%28lib._hash-lambda%2Fmain..rkt%29._apply%2Fhash%29%29 On Mar 25, 2015, at 11:06 AM, Laurent wrote: > Or you can use dictionaries to pass keyword values (similar to Python): > https://gist.github.com/Metaxal/578b473bc48886f81123 -- 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] accumulators vs foldl? was: Fwd: Rsound question
This is a pedagogic question. The discussion below (forwarded with permission) is basically about the best way to find the maximum value in a vector of length four million, a.k.a. a sound file. Non-tail recursion is problematic; I blow a 512M-limited evaluator in about 14 seconds without finding the answer, where tail-calling gets me the answer in about 2 seconds. So! Here’s the question. Is it better to give students an “rs-foldl” that performs a fold over sound, or to show them accumulator-style programming? I was a bit surprised to see that in HtDP 2e, foldl (a.k.a. “Programming to an Abstraction”) appears much earlier (section 18.4) than accumulator-style (section 35). I suppose this could be because using an abstraction can be easier than devising it, although in the case of (say) map, the book takes care to ensure that students can implement map-like functions in their sleep before showing them the abstraction. Opinions appreciated! Many thanks, John Begin forwarded message: > From: John Clements > Subject: Re: Rsound question > Date: March 25, 2015 at 9:48:09 AM PDT > To: James Vanderhyde > > > On Mar 25, 2015, at 5:54 AM, James Vanderhyde > wrote: > >> John, >> >> There are some sound processing tasks I’m not sure how to do with Rsound. >> For example, to normalize the sound (make it as loud as possible with no >> clipping), I need to find the maximum absolute sample value, and then >> multiply everything by 1 over that value. I can use rs-map for the second >> part, but I don’t know how to find the max in a sound (or do other audio >> analysis). It seems like I need something like rs-fold. What would you >> recommend? > > I see two ways to solve this. The first is “by the book”. > > FIRST: > > This problem requires two medium-advanced concepts. First, the notion of > recursion over the natural numbers, introduced in section 10.3 of HtDP2e > > http://www.ccs.neu.edu/home/matthias/HtDP2e/part_two.html#%28part._sec~3anats%29 > > … and, more challenging, the notion of an accumulator: > > http://www.ccs.neu.edu/home/matthias/HtDP2e/part_six.html > > Here’s the resulting code: > > (require rsound) > > ;; given a sound, return the maximum value > ;; of a sample in that sound > ;; rsound -> number > (define (max-volume rs) > (max-volume-helper rs 0 0.0)) > > ;; given a sound, an index, and a maximum-so-far, > ;; compute the maximum volume of the sound > (define (max-volume-helper rs idx max-so-far) > (cond [(<= (rs-frames rs) idx) max-so-far] >[else (max-volume-helper rs (add1 idx) > (max (abs (rs-ith/left rs idx)) > (abs (rs-ith/right rs idx)) > max-so-far))])) > > (define test-sound (mono 101 x (* -0.0025 x))) > > (check-within (max-volume-helper test-sound 50 0.0) 0.25 1e-4) > (check-within (max-volume-helper test-sound 50 0.96) 0.96 1e-4) > (check-within (max-volume test-sound) 0.25 1e-4) > > In this case, the accumulator isn’t really necessary, but if you want to run > the program on more than a few hundred samples, it’s going to be important. > > SECOND: > > We could certainly add rs-fold. It would require students to define a more > challenging higher-order function, but perhaps that’s simpler than writing it > in accumulator style? I’d be interested to hear what you have to say. > > P.S.: mind if I forward this question to the racket-users mailing list? > > John > > > >> >> James >> -- >> Dr. James Vanderhyde >> Math and Computer Science >> Benedictine College >> jvanderh...@benedictine.edu >> http://vanderhyde.us/~james/pro/ >> >> >> >>> On Mar 18, 2015, at 2:24 PM, John Clements >>> wrote: >>> >>> >>> On Mar 18, 2015, at 6:28 AM, James Vanderhyde >>> wrote: >>> Thank you, John. You are so helpful. I’ve really appreciated your quick responses. I don’t really like mono because it introduces additional syntax, and signals introduce additional structures. But either one will give me a much better approach than what I was going to do. >>> >>> Thanks for the thanks! Also, I’d like to point out that if you use >>> indexed-signal, you certainly don’t need to get into details; you can >>> describe a signal as a box with a function in it. >>> >>> HOWEVER… after looking at this for a while longer, I see that a >>> ‘build-sound’ function such as the one you describe is probably a good >>> addition to the library. So, I added it. (I also >>> added some other documentation, and fixed one long-term documentation >>> niggle). >>> >>> I’ve pushed this to the github repo, and poked pkgs.racket-lang.org. I’m >>> not sure how long it’ll take for the catalog to reflect the change. >>> >>> Thanks again, >>> >>> John Clements >>> >>> By the way, rs-map is also undocumented. James -- Dr. James Vanderhyde Math and Computer Science Benedictine College jvander
Re: [racket-users] apply: pass keywords to function?
Hi Alexander, I think the immediate issue is solved. I need to look at the links you provided - they may be helpful in the future. Thanks for all your help. George On 3/24/2015 5:05 PM, Alexander D. Knauth wrote: On Mar 22, 2015, at 7:42 PM, George Neuner wrote: > I thought about case-lambda, but it doesn't permit keywords like a > normal lambda. For that: http://pkg-build.racket-lang.org/doc/hash-lambda-toc/keyword-case-lambda.html Although I’m not sure how it would help for this case. > I've tried things like > (apply in-query (list* (list* dbc sql args) >(list (string->symbol "fetch") n))) > > to mimic the unwrapped call, but so far I've had no luck. Although it’s not really a good idea (see below), you might also be interested in: https://github.com/AlexKnauth/kw-utils/blob/master/kw-utils/kw-apply.rkt You would use it like this: (apply/kw in-query (list* dbc sql ‘#:fetch n args)) However, if any of the other arguments happen to be values representing keywords, it will either break or do something weird. Instead, a few better options: (apply in-query dbc sql #:fetch n args) Or, if you can’t do that because the keyword you need is a value determined at runtime: http://docs.racket-lang.org/reference/procedures.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._keyword-apply%29%29 (keyword-apply in-query ‘(#:fetch) (list n) dbc sql args) Or, if there might be multiple keywords and you don’t feel like sorting them yourself: http://pkg-build.racket-lang.org/doc/kw-utils/keyword-apply-sort_scrbl.html (keyword-apply/sort in-query ‘(#:fetch) (list n) dbc sql args) -- 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] Projects (was: the Racket manifesto)
I think this only prohibits projects as an 'extra linguistic' mechanism. I think extending #lang info is probably fine? Maybe even a '#lang project' would be ok? (but I'm not sure what that would do) S. --- 3. Racket turns extra-linguistic mechanisms into linguistic constructs. When programmers must resort to extra-linguistic mechanisms to solve a problem, the chosen language has failed them --- On Wed, 25 Mar 2015 at 14:25, Laurent wrote: > In the manifesto, I'm a bit surprised by the following: > >> this philosophy prohibits the idea of “projects,” as found in other IDEs, >> because this also externalizes resource management, linking, and other >> aspects of program creation. > > > Couldn't one call package designing a project? > Sure, a package can depend on other packages, but that's true for any > "project". And when I'm building a package, I'm mostly editing the source > files of this package in parallel. You can even tell which files are in the > same project *within* a rkt source file, by looking at the `require`s. > > I'd be happy to have an official automatic generation of the info.rkt with > dependencies and doc stubs and other small things related to package design > (as as been done by others). I can definitely understand that it's not your > priority, but merely dismissing the idea "projects" altogether seems > strange. > > Or maybe I'm misunderstanding the idea here? > > -- > 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] Projects (was: the Racket manifesto)
Thank you Greg. I couldn't have said it any better (probably worse). This is exactly the point -- Matthias On Mar 25, 2015, at 12:07 PM, Greg Hendershott wrote: > My personal/casual take on this: > > There are language systems where you to need to run some > make-a-new-project tool -- even for a single source file. > > In Racket you can create multi-file collections without needing such a > tool. Only at the point where you want to package it share with > others, do you maybe need a tiny info.rkt. > > And I think the philosophy is that even this is sort of unfortunate, > and should be as minimal as possible. For example if it were feasible > to omit `deps` and `build-deps`, and have those automatically > determined (not automatically genreated in info.rkt), that would be > preferable. In many cases that would leave info.rkt containing only > metadata like `version`. I could imagine even that instead going in > main.rkt as a special identifier and/or submodule or whatever. > > So I understand the manifesto as saying, even if it turns out to be > impractical short- or long-term, the ideal and the starting point > should be "no external tools and config files". > > Also Racket has a macro system that means you probably never need to > resort to source-file-generating/munging tools, which can be a big > chunk of the ecosystem in some languages. -- 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] the Racket manifesto
On Mar 24, 2015, at 11:15 PM, Matthias Felleisen wrote: > On Mar 24, 2015, at 10:34 PM, Neil Van Dyke wrote: > >> Shortly after I declare that Racket is not a cult, Racket goes and issues a >> manifesto. >> >> Neil V. Neil, I wrote this paper _because_ academia perceives Racket as a cult. The reactions from academics has been nothing but great so far (tested locally) and I am hoping it will help my future students with entry into academia, which I consider Racket's home base (not that there aren't and shouldn't be others). The word in the title is a compromise. I would have preferred 'platform' but my co-authors didn't find it 'groany' enough. I do not consider it a mockery of anything. It simply says that this is the vision we have had for Racket and that we will continue to work on. -- Matthias -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Projects (was: the Racket manifesto)
My personal/casual take on this: There are language systems where you to need to run some make-a-new-project tool -- even for a single source file. In Racket you can create multi-file collections without needing such a tool. Only at the point where you want to package it share with others, do you maybe need a tiny info.rkt. And I think the philosophy is that even this is sort of unfortunate, and should be as minimal as possible. For example if it were feasible to omit `deps` and `build-deps`, and have those automatically determined (not automatically genreated in info.rkt), that would be preferable. In many cases that would leave info.rkt containing only metadata like `version`. I could imagine even that instead going in main.rkt as a special identifier and/or submodule or whatever. So I understand the manifesto as saying, even if it turns out to be impractical short- or long-term, the ideal and the starting point should be "no external tools and config files". Also Racket has a macro system that means you probably never need to resort to source-file-generating/munging tools, which can be a big chunk of the ecosystem in some languages. -- 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] Urgent REQ:Job Title: System Admin Location: NYC,NY
Hello* Partner,* Hope you are doing great. Please let me know if you have any suitable profile for the below position. * Plz send me resume ASAP* * khalandhar@gmail.com * *Job Title:* System Admin *Location: *NYC,NY *Duration:* 6+ Months Contract *Rate*: DOE *Required Skill:* 10+ years exp as a System Admin -Strong AWS experience - Good PHP -Some knowledge or exp with PUPPET or CHEF *Thanks and Regards,* Javeed Mohammad IT Recruiter *|* National Consulting Group Inc. 15 Corporate Place South, Suite - 419, Piscataway, NJ 08854, USA. ' 908-333-5825 -- 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] apply: pass keywords to function?
Or you can use dictionaries to pass keyword values (similar to Python): https://gist.github.com/Metaxal/578b473bc48886f81123 On Tue, Mar 24, 2015 at 9:05 PM, Alexander D. Knauth wrote: > > On Mar 22, 2015, at 7:42 PM, George Neuner wrote: > > > I thought about case-lambda, but it doesn't permit keywords like a > > normal lambda. > > For that: > > http://pkg-build.racket-lang.org/doc/hash-lambda-toc/keyword-case-lambda.html > > Although I’m not sure how it would help for this case. > > > I've tried things like > > (apply in-query (list* (list* dbc sql args) > >(list (string->symbol "fetch") n))) > > > > to mimic the unwrapped call, but so far I've had no luck. > > Although it’s not really a good idea (see below), you might also be > interested in: > https://github.com/AlexKnauth/kw-utils/blob/master/kw-utils/kw-apply.rkt > You would use it like this: > (apply/kw in-query (list* dbc sql ‘#:fetch n args)) > > However, if any of the other arguments happen to be values representing > keywords, it will either break or do something weird. > > Instead, a few better options: > > (apply in-query dbc sql #:fetch n args) > > Or, if you can’t do that because the keyword you need is a value > determined at runtime: > > http://docs.racket-lang.org/reference/procedures.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._keyword-apply%29%29 > (keyword-apply in-query ‘(#:fetch) (list n) dbc sql args) > > Or, if there might be multiple keywords and you don’t feel like sorting > them yourself: > http://pkg-build.racket-lang.org/doc/kw-utils/keyword-apply-sort_scrbl.html > (keyword-apply/sort in-query ‘(#:fetch) (list n) dbc sql args) > > > -- > 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] Projects (was: the Racket manifesto)
In the manifesto, I'm a bit surprised by the following: > this philosophy prohibits the idea of “projects,” as found in other IDEs, > because this also externalizes resource management, linking, and other > aspects of program creation. Couldn't one call package designing a project? Sure, a package can depend on other packages, but that's true for any "project". And when I'm building a package, I'm mostly editing the source files of this package in parallel. You can even tell which files are in the same project *within* a rkt source file, by looking at the `require`s. I'd be happy to have an official automatic generation of the info.rkt with dependencies and doc stubs and other small things related to package design (as as been done by others). I can definitely understand that it's not your priority, but merely dismissing the idea "projects" altogether seems strange. Or maybe I'm misunderstanding the idea here? -- 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] Why are SQLITE queries so slow?
Hi, I'm new to Racket, and i would like to know why sqlite queries are so slow in my test program. This program imports some data from a text file into a simple sqlite DB. It takes 35s with the INSERT queries and 5-6s without them. I've done the same thing with other languages, all do far better. For example with perl the same code runs in 8s with the queries, and 2-3s with them. I know that startup and regex are (reasonably ?) slower in racket, but queries seems to be very slow. Am i doing somethin wrong? Thanks for your help. test done by swapping the commented line with the next. Code : - #!/usr/bin/env racket #lang racket/base (require racket/list racket/string db/base db/sqlite3) (define DBFILE "database.rkt.sql") (define rx #rx"[~^]+") (define sdb #f) (define (openDatas) (unless sdb (set! sdb (sqlite3-connect #:database DBFILE (define (importDatas) (when (file-exists? DBFILE) (delete-file DBFILE)) (set! sdb (sqlite3-connect #:database DBFILE #:mode 'create)) (start-transaction sdb) (query-exec sdb "CREATE TABLE groups (fam INTEGER, name STRING , PRIMARY KEY (fam))") (query-exec sdb "CREATE TABLE foods (alim INTEGER, fam INTEGER, name STRING , PRIMARY KEY (alim))") (query-exec sdb "CREATE TABLE nutrients (nutr INTEGER, unit STRING, short STRING, name STRING , PRIMARY KEY (nutr))") (query-exec sdb "CREATE TABLE contents (alim INTEGER, nutr INTEGER, val FLOAT , PRIMARY KEY (alim, nutr))") (process-file "FD_GROUP.txt" "groups"2) (process-file "FOOD_DES.txt" "foods" 3) (process-file "NUTR_DEF.txt" "nutrients" 4) (process-file "NUT_DATA.txt" "contents" 3) (commit-transaction sdb)) (define (process-file fname table nb) (define Q (prepare sdb (string-append "INSERT INTO " table " VALUES (" (string-join (for/list ([x nb]) "?") ",") ")"))) (call-with-input-file fname (lambda (file) (for ([line (in-port read-line file)]) ;(bind-prepared-statement Q (take (regexp-split rx line 1) nb)) (query-exec sdb (bind-prepared-statement Q (take (regexp-split rx line 1) nb))) (importDatas) - -- 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.