[racket-users] NEED || Sr. Oracle Functional Consultant || Billerica, MA
Hi, This is Aanchal from Technology resource Group. Below is the job description and requirements for your perusal and please contact me if having any questions or concerns. *OPENINGS: 2* *Role: Sr. Oracle Functional Consultant* *Location: Billerica, MA* *Duration: 6 Months (Extension possible)* *Interview Mode: Telephonic Interview followed by Skype* *Job Description:* *Must be very Sr. 9-10 + years of experience.* *Domain: Costing, Billing and Project Manufacturing* *Accounting, costing, billing and manufacturing will be key and they need to be Sr. resources.* Thanks and Regards, Aanchal Arora | Technical Recruiter Technology Resource Group Inc. 3736 Hillsdale Court Santa Clara, CA 95051 Office:408-709-1760 Ext : 812 | Direct: 408-826-8378 Gtalk/YM: http://www.tresourceinc.com/ aanchalarora825 | Fax: 408-884-2409 aanc...@tresourceinc.com | www.tresourceinc.com -- 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] Molis Hai -- passwords generated from Dickens
About six months ago, I had an idea on how to generate passwords from English text while still maintaining entropy. I wrote it up quickly on ArXiv, and published a web page where you can try it: http://www.brinckerhoff.org/molis-hai/ I’ve now released it as a raco command-line tool, too. You can install it with raco pkg install molis-hai ...and run it with raco molis-hai Unlike the online version, the command-line tool allows you to specify your own corpus, order, and number of passwords generated. On the command-line, it uses bits from /dev/urandom. Give it a try! John Clements -- 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: HTTP Cookies
Sorry for the lame subject; that was the draft subject and I forgot to changing it before posting. -- 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] HTTP Cookies
TLDR; How to store use HTTP cookies across multiple requests in an HTTP client? I'm trying to fetch a URL and, say, print the cookies it sets. Fetching a URL is easily done with `call/input-url`, however it doesn't handle HTTP response headers (incl. cookies). There are `http-conn-open`, `http-conn-send!` and `http-conn-recv!` which, happily, let one do all sorts of stuff with HTTP request/response headers. Trying to combine them[1] with net-cookies[2], nothing gets set in the cookie jar[3]. I tried printing all HTTP response headers to check for cookies but there were no Set-Cookie headers. So, what am I doing wrong here? I'd appreciate any hint/help on this. [1] (let [(conn (http-conn-open SOME_URL #:ssl? #t))] (http-conn-send! conn SOME_URI #:method #POST #:data post-data) (let-values ([(status-line header-list inport) (http-conn-recv! conn)]) (extract-and-save-cookies! (map (λ (x) ;;; I have a feeling this could have been done better. (let [(hs (string-split (bytes-string/latin-1 x) :))] (cons (string-bytes/latin-1 (first hs)) (string-bytes/latin-1 (second hs) header-list) (string-url SOME_URL [2] http://pkg-build.racket-lang.org/doc/cookies/index.html [3] (cookie-header SOME-URL) = #f -- 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] Closing big-bang windows
On Jun 22, 2015, at 11:31 AM, Jens Axel Søgaard jensa...@soegaard.net wrote: John Carmack: My son's game has a level editor as well as a game loop, and we switch between them. However, each new big-bang call creates a new window, leaving the previous ones inert on the screen. How can we close the windows? Matthias Felleisen: But people wanted it to stay open so that they could see the final score of their games etc. I guess I could add a close-on-stop clauses for programmers such as your son but it sounds almost like he's ready to move on to racket proper, as in use the Windowing API directly. If I understand correctly, a manual (close-all-big-bang-windows) callable from the REPL would be enough in this case? This is where teaching comes in, How do you justify a function of NO arguments with the rules of algebra? So far this design guideline has produced the smoothest possible path from pre-algebra courses through Bootstrap, Program By Design, Picturing Programs, HtDP, all the way to 'Hell' (that's my software dev course for juniors). [Even if the programmers/students don't get it, straying from this design principle has always gotten me into trouble eventually.) -- 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] no plot zooming on local build--update procedure wrong?
Yes, sorry about that everyone. Poor planning on my part. Robby On Monday, June 22, 2015, Neil Toronto neil.toro...@gmail.com wrote: Robby has just pushed an evil hack that makes plots and pict3ds interactive again. In the future, there will be a transition to a different interactive values API, but it'll go a lot smoother. Neil ⊥ On 06/21/2015 12:34 PM, Neil Toronto wrote: It's because of this: https://groups.google.com/forum/#!topicsearchin/racket-dev/subject$3Asnip/racket-dev/Sqoeg1JX-wM (If anyone knows of a nicer way to link to Google Groups posts, I'd love to know what it is.) Getting this (and Pict3D) working again on master is next on my to-do list. Neil ⊥ On 06/16/2015 11:30 PM, Matthew Butterick wrote: I've had the same issue with plot zooming not working from my git build. I don't have a theory but it at least suggests the problem may not be strictly localized. On Jun 16, 2015, at 1:10 PM, 'John Clements' via users-redirect us...@plt-scheme.org wrote: I notice that currently, plot snips are not zoomable in my local build. The release candidate doesn’t seem to have this problem. I believe I’ve had this problem since before the release candidate was built. This suggests to me that the problem is not that there’s a bug in the code, but rather that my installation is messed up somehow. I’m up to date on the git.racket-lang.org repo, and I just ran ‘make’, and I’m still seeing the problem. I’m guessing that I could fix this by discarding my tree and building again from scratch, but if my update procedure is wrong (git fetch then ‘make’), I’ll keep having this problem again and again. Any ideas? Many thanks, John -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Re: Converting a heterogenous list into a string
On Monday, 22 June 2015 16:46:39 UTC+4:30, Daniel Prager wrote: (apply ~a (map (λ (x) (apply format [~a=~a] x)) paired-list)) I like it! I had totally forgotten about `apply`. BTW: In DrRacket you can get the λ by using Cmd+\ (on Mac, shortcut listed in the Insert file menu). Thanks for the tip...didn't know that. -- 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] no plot zooming on local build--update procedure wrong?
Robby has just pushed an evil hack that makes plots and pict3ds interactive again. In the future, there will be a transition to a different interactive values API, but it'll go a lot smoother. Neil ⊥ On 06/21/2015 12:34 PM, Neil Toronto wrote: It's because of this: https://groups.google.com/forum/#!topicsearchin/racket-dev/subject$3Asnip/racket-dev/Sqoeg1JX-wM (If anyone knows of a nicer way to link to Google Groups posts, I'd love to know what it is.) Getting this (and Pict3D) working again on master is next on my to-do list. Neil ⊥ On 06/16/2015 11:30 PM, Matthew Butterick wrote: I've had the same issue with plot zooming not working from my git build. I don't have a theory but it at least suggests the problem may not be strictly localized. On Jun 16, 2015, at 1:10 PM, 'John Clements' via users-redirect us...@plt-scheme.org wrote: I notice that currently, plot snips are not zoomable in my local build. The release candidate doesn’t seem to have this problem. I believe I’ve had this problem since before the release candidate was built. This suggests to me that the problem is not that there’s a bug in the code, but rather that my installation is messed up somehow. I’m up to date on the git.racket-lang.org repo, and I just ran ‘make’, and I’m still seeing the problem. I’m guessing that I could fix this by discarding my tree and building again from scratch, but if my update procedure is wrong (git fetch then ‘make’), I’ll keep having this problem again and again. Any ideas? Many thanks, John -- 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] Macro-introducing macros with inter-macro communication channel
Thanks for the effort that went into figuring that out! A couple first thoughts on the implementation: To first order, this is exactly what I want to be able to do (and it elegantly avoids local-expand by reasoning about expansion order); however, as a general pattern, it's a bit unhygienic in that Accum is now in the global namespace, which precludes using it as a child macro for other constructs, and prevents specific instantiations of Loop from requesting a different name for Accum to cooperate in nested loops. I also noticed that (syntax-parameterize) isn't totally transparent in the expanded syntax - it leaves a bunch of empty (let-values () ...) behind, which is fine for Racket, but problematic in my target use-case of emitting something which ultimately needs to be an entirely different language. This is why my experiments have all involved local-expand - I want to introduce expand-time names without introducing wrapping let-syntaxes (or similar) forms around my body code. On Saturday, June 20, 2015 at 2:24:40 PM UTC-4, Alex Knauth wrote: On Jun 19, 2015, at 7:44 PM, Thomas Dickerson thomas_dicker...@brown.edu wrote: I was intending for that example to have the variables be defined outside the macro, but being able to create the (set! ...) forms outside should mean I could also hypothetically create let/define-values forms. This is why I originally specified being able to effect generation of both prologue + epilogue code. I figured this out for code that will be expanded after the body: #lang racket/base (require racket/stxparam (for-syntax racket/base syntax/parse racket/set )) ;; (syntax-parameter-value vars) : (U #f (MutableSetof Identifier)) (define-syntax-parameter vars #f) (define-syntax Accum (lambda (stx) (syntax-parse stx [(Accum x:id dx:expr) (define vs (syntax-parameter-value #'vars)) (unless (set-mutable? vs) (raise-syntax-error #f cannot be used outside Loop stx)) (set-add! vs (syntax-local-introduce #'x)) #'(set! x (+ x dx))]))) (define-syntax set-accums-zero! (syntax-parser [(set-accums-zero!) #:with [x ...] (map syntax-local-introduce (set-list (syntax-parameter-value #'vars))) #'(begin (set! x 0) ...)])) (define-syntax Loop (syntax-parser [(Loop up-to-expr:expr body:expr ...+) #'(syntax-parameterize ([vars (mutable-set)]) (let ([up-to up-to-expr]) (letrec ([loop (lambda (n) body ... (if ( n up-to) (loop (add1 n)) (void)))]) (set-accums-zero!) (loop 0])) (let ([x x] [y y] [z z]) (Loop 10 (begin (define-values [dx dy dz] (values 1 2 3)) (printf x = ~v, y = ~v, z = ~v\n x y z) (Accum x dx) (Accum y dy) (Accum z dz To generate a let outside of that you’d probably need to do some kind of local-expand, but I’m not sure. -- 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] drawing with canvas
The docs here might help elaborate on Matthias's answer: http://docs.racket-lang.org/gui/canvas___.html I'll try adding more links to that information, including from the `get-dc` method. Maybe it also would be better as its own section in the overview chapter. At Mon, 22 Jun 2015 18:07:04 -0400, Matthias Felleisen wrote: [[ I am tempted to say that you misplaced the parentheses and brackets and broke lines at the wrong place. ]] Here is a re-ordering of the first don't work variant that kind of works: #lang racket (require slideshow racket/class racket/gui/base) (define my-frame (new frame% [label my frame] [width 300] [height 300] [alignment '(center center)])) (define my-canvas (new canvas% [parent my-frame])) (define my-dc (send my-canvas get-dc)) (send my-frame show #t) (draw-pict (circle 60) my-dc 40 40) (sleep 1) Stop! This should give you a hint of why you need to have an callback function in this world. In this world, many different events affect the visible canvas and it needs to refresh itself all the time. Omitting the callback says draw nothing when you refresh. On Jun 22, 2015, at 2:17 PM, Mianlai Zhou mianlai.resea...@gmail.com wrote: Hi people, I am wondering why this segment of code failed to work: ; don't work #lang racket (require slideshow racket/class racket/gui/base) (define my-frame (new frame% [label my frame] [width 300] [height 300] [alignment '(center center)] )) (define my-canvas (new canvas% [parent my-frame] )) (define my-dc (send my-canvas get-dc)) (draw-pict (circle 60) my-dc 40 40) (send my-frame show #t) While the following codes *do* work: ; do work #lang racket (require slideshow racket/class racket/gui/base) (define my-frame (new frame% [label my frame] [width 300] [height 300] [alignment '(center center)] )) (define my-canvas (new canvas% [parent my-frame] [paint-callback (lambda (self dc) (draw-pict (circle 60) dc 40 40) )] )) (send my-frame show #t) Is there anyway to avoid using redefining paint-callback to draw one or more pictures on the canvas, as in the first example? Thanks in advance for your answer, Mianlai -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] drawing with canvas
[[ I am tempted to say that you misplaced the parentheses and brackets and broke lines at the wrong place. ]] Here is a re-ordering of the first don't work variant that kind of works: #lang racket (require slideshow racket/class racket/gui/base) (define my-frame (new frame% [label my frame] [width 300] [height 300] [alignment '(center center)])) (define my-canvas (new canvas% [parent my-frame])) (define my-dc (send my-canvas get-dc)) (send my-frame show #t) (draw-pict (circle 60) my-dc 40 40) (sleep 1) Stop! This should give you a hint of why you need to have an callback function in this world. In this world, many different events affect the visible canvas and it needs to refresh itself all the time. Omitting the callback says draw nothing when you refresh. On Jun 22, 2015, at 2:17 PM, Mianlai Zhou mianlai.resea...@gmail.com wrote: Hi people, I am wondering why this segment of code failed to work: ; don't work #lang racket (require slideshow racket/class racket/gui/base) (define my-frame (new frame% [label my frame] [width 300] [height 300] [alignment '(center center)] )) (define my-canvas (new canvas% [parent my-frame] )) (define my-dc (send my-canvas get-dc)) (draw-pict (circle 60) my-dc 40 40) (send my-frame show #t) While the following codes *do* work: ; do work #lang racket (require slideshow racket/class racket/gui/base) (define my-frame (new frame% [label my frame] [width 300] [height 300] [alignment '(center center)] )) (define my-canvas (new canvas% [parent my-frame] [paint-callback (lambda (self dc) (draw-pict (circle 60) dc 40 40) )] )) (send my-frame show #t) Is there anyway to avoid using redefining paint-callback to draw one or more pictures on the canvas, as in the first example? Thanks in advance for your answer, Mianlai -- 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] Re: Converting a heterogenous list into a string
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] Thank you Jon, Robby and Matthias for the help. The point about the input data representation makes sense, and happily in this case, the code base is mine; so it's easy to fix the flaw. The solution that does this by using `match`, could be, as well, done with the following: (string-join (map (lambda (x) (format [~a=~a] (first x) (second x))) paired-list) ) Which one is preferred? And finally, I'm curious, why such a procedure is not already in the standard library? Is it simply because my use case is not common at all? -- 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] Closing big-bang windows
On Sun, Jun 21, 2015 at 10:18 PM, Neil Toronto neil.toro...@gmail.com wrote: On 06/21/2015 02:54 PM, Alexis King wrote: I guess I could add a close-on-stop clauses for programmers such as your son but it sounds almost like he's ready to move on to racket proper, as in use the Windowing API directly. FWIW, despite big-bang’s position as a teaching tool, I much prefer it over using the Windowing API directly, considering it provides a pure interface for working with real-time graphical applications. I like big-bang’s approach to that problem, and I’ve found myself using it many times due to its ease of use. In contrast, racket/gui is frustratingly imperative. He may also be interested in Jay's variant of 'universe', which is faster (and comes with sound) or Neil's (experimental) 3D version. I conjecture that they are both more open to extensions than my teaching versions Absolutely. I’m aware of pict3d/universe, but I admit I haven’t heard of Jay’s version. Is that what lux is? (Either way, it would be nice to get the docs building properly on pkg-build, since currently the build fails.) pict3d/universe supplies `big-bang3d`, which is like `big-bang` but is slimmed down (e.g. no pad overlay) and takes keyword arguments instead of special syntax. It also supplies game time and frame count to each function, and makes explicit guarantees about threading and event order. And it doesn't try as hard to tell you what you did wrong. Jay's lux provides an abstract framework for game-like programs. It's easy to make adapters for different ways to render games that plug into it. (I've done it for Pict3D, for example.) The best thing going for it is its generic interface, which saves programmers from having to do top-level dispatch based on game mode in every callback function. Anyway, I think it would be nice to have something like 2htdp/universe that’s aimed at more experienced programmers. If lux is designed to be that, I’ll certainly take a look. Otherwise, would it be worth spending some time figuring out how to generalize and scale the ‘universe’ idiom to be a bit more powerful? Jay's lux and my `big-bang3d` are both small steps in that direction. FWIW, while `big-bang3d` is experimental, its current form will remain a stable subset of the API, and it works well. I'm working on a `big-bang3d` game intended to expose shortcomings in universe-style programs when used at a larger scale than in the classroom. Here are my main criticisms so far: 1. Adding new state is painful. Every time I add a little bit to track something - a cooldown timer, camera momentum, a list of planes the player collided against - I have to change a lot of unrelated code. 2. Adding a new game mode (e.g. menus, level editor) involves a lot of boilerplate. 3. We don't have a good story for sound. 4. Paying the garbage collector can get expensive. Figuring out how to not pay it so much is next to impossible at the moment. For #1, I think we need nicer ways to reach deep into heterogeneous data structures to read from and update them. Refactoring data structures only goes so far. Game state is a big, messy thing with a lot of interaction that defies neatly compartmentalized trees. In my existing games, I do two major things. First, I typically use a giant functional hash table with gensym allocated keys and without the ability to iterate through them. This gives abstraction and pretty nice flexibility. The other thing I do is make each entity system in the game be a separate cooperative thread, so that I can capture most of the state in the continuation and the recursive arguments. A really simple example is here: https://github.com/jeapostrophe/dos/blob/master/dos/examples/win.rkt The mouse-tracking-ball uses the recursive argument for its radius and the decaying-ball uses its continuation to storage where in the count-down it is. This all implemented by the DOS package, primarily the win library. http://pkg-build.racket-lang.org/doc/dos/index.html (It would also be nice to have support for batching all the updates for performance. This could also make it easy to send state deltas over the network.) I'm presently working on an entity-component-system library that supports abstract state and processors that is compiled to large homogenous arrays and batch processing. But it's a ways off. Having tried Jay's generics solution, I think it nearly solves #2. I wish generics were better supported in both typed and untyped Racket. I think we imagine #3 is harder than it really is. Quake III Arena's engine API basically has just start/keep playing this, stop playing this, and move the source of this sound here. IMO the only real design issue is figuring out how programmers name sounds so they can refer to them later. (Engineering-wise, we need a mixer running in a separate thread/place that big bang programs can issue commands to over an async
Re: [racket-users] Re: Defining contracts sanely
On Mon, Jun 22, 2015 at 2:43 AM, Aidan Gauland aidal...@slingshot.co.nz wrote: If this does what you want, it’s fine, but the define/contract is probably unnecessary, and (define fish-freshness/c (flat-named-contract ‘fish-freshness/c (lambda (x) (not (eq? ….) Should do what you want. So are contracts on contracts generally unnecessary? No, the right generalization to draw here is that contracts aren't necessary when it is obvious that they can never signal blame. As another example, this: (define/contract (f x) (- integer?) 3) isn't really a helpful contract. The reason why the other generalization isn't right has to do with the fact that contracts are themselves code and, like all code, can be buggy. If you want to check out some recently-written complex contracts, check out the data/enumerate library: http://docs.racket-lang.org/data/Enumerations.html Robby -- 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: Defining contracts sanely
On 22/06/15 04:26, Alexander D. Knauth wrote: On Jun 21, 2015, at 5:41 AM, Aidan Gauland wrote: Say I want to define a flat contract for the freshness field of my fish class, so I define a contract for it like so: (define/contract fish-freshness/c (- any/c boolean?) (flat-named-contract 'fish-freshness/c (lambda (x) (not (eq? #f (member x '(fresh frozen edible rotten))) Am I barking up the wrong tree here, or is this perfectly sensible? If this does what you want, it’s fine, but the define/contract is probably unnecessary, and (define fish-freshness/c (flat-named-contract ‘fish-freshness/c (lambda (x) (not (eq? ….) Should do what you want. So are contracts on contracts generally unnecessary? The flat-named-contract is also probably unnecessary (though it can be useful if the name isn’t just a symbol), so (define (fish-freshness/c x) (not (eq? ….))) Will also do what you want. This just defines a procedure, not a `flat-contract' type. (Although I admit I am unclear on what is special about a flat-contract.) And finally, another way of doing this would be: (define fish-freshness/c (or/c ‘fresh ‘frozen ‘edible ‘rotten)) Or if you prefer giving the contract a better name for error messages: (define fish-freshness/c (flat-named-contract ‘fish-freshness/c (or/c ‘fresh ‘frozen ‘edible ‘rotten))) Ah, I didn't realise that or/c could be used like this. That's much simpler when the condition is simply is one of these symbols. Any one of these is “sane” as long as they work, and it depends on which one you think looks more readable, makes you’re intent clear, and gives error messages that make sense. I suppose cleanly would have been a better word for the thread subject, since I would have to be really clueless to be unsure whether my code is sane. :P I just finished this when I saw Matthias Felleisen’s reply. I’m sending it anyway. I appreciate it. His solution was taking my toy example a little too seriously, although I may have to steal it for my fish client/server. ;) I see he uses one-of/c, which is deprecated in favour of or/c (according to the Racket 6.1.1 Reference). -- 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] db: nested transactions
Hi all, I have what I hope is a quick question. WIth appropriate care to pair start and commit/rollback, is it safe to use call-with-transaction and start-transaction together? e.g., (call-with-transaction dbc (lambda () : (start-transaction dbc #:isolation 'serializable) : (if (needs-rollback? dbc) (rollback-transaction dbc) (commit-transaction dbc)) : ) #:isolation 'read-committed ) or the reverse: (start-transaction dbc #:isolation 'repeatable-read) : (call-with-transaction dbc (lambda () : ) #:isolation 'serializable) : (if (needs-rollback? dbc) (rollback-transaction dbc) (commit-transaction dbc)) I am adding functionality involving sub-transactions to an existing code base that uses call-with-transaction pretty much exclusively and I'm hoping not to have to change the existing framework. Thanks, 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] db: nested transactions
On 22/06/2015 11:05, George Neuner wrote: Hi all, I have what I hope is a quick question. WIth appropriate care to pair start and commit/rollback, is it safe to use call-with-transaction and start-transaction together? e.g., (call-with-transaction dbc (lambda () : (start-transaction dbc #:isolation 'serializable) : (if (needs-rollback? dbc) (rollback-transaction dbc) (commit-transaction dbc)) : ) #:isolation 'read-committed ) or the reverse: (start-transaction dbc #:isolation 'repeatable-read) : (call-with-transaction dbc (lambda () : ) #:isolation 'serializable) : (if (needs-rollback? dbc) (rollback-transaction dbc) (commit-transaction dbc)) I am adding functionality involving sub-transactions to an existing code base that uses call-with-transaction pretty much exclusively and I'm hoping not to have to change the existing framework. Thanks, 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 mailto:racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. The documentation says: Calling either commit-transaction or rollback-transaction when the open transaction was created by call-with-transaction causes an exception to be raised. But they can be nested by further call-with-transaction calls, it says. Last time I did an O/R mapper (in Java) I decided to put in a safety belt and use transaction tokens because non local jumps in GUI code are known to occur and involontary nesting may be hard to detect. My O/R mapper requested to use a valid transaction token from the GUI code each time an object wanted to start a transaction. Different transaction used different tokens and unmatched tokens produced an error. I think I saw three of these error conditions packed nicely into error messages - all in all three of them with testing included. There is the overhead of token passing but it's still worth it. BTW Requesting isolation level support info from MySQL DB made me shudder back then: or there was some hidden HyperOracle release beneath mysql or that thing just lied about it's capabilities. -- 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] drawing with canvas
Hi people, I am wondering why this segment of code failed to work: ; don't work #lang racket (require slideshow racket/class racket/gui/base) (define my-frame (new frame% [label my frame] [width 300] [height 300] [alignment '(center center)] )) (define my-canvas (new canvas% [parent my-frame] )) (define my-dc (send my-canvas get-dc)) (draw-pict (circle 60) my-dc 40 40) (send my-frame show #t) While the following codes *do* work: ; do work #lang racket (require slideshow racket/class racket/gui/base) (define my-frame (new frame% [label my frame] [width 300] [height 300] [alignment '(center center)] )) (define my-canvas (new canvas% [parent my-frame] [paint-callback (lambda (self dc) (draw-pict (circle 60) dc 40 40) )] )) (send my-frame show #t) Is there anyway to avoid using redefining paint-callback to draw one or more pictures on the canvas, as in the first example? Thanks in advance for your answer, Mianlai -- 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] Re: Fast way to map over a list many times, changing ONE element each time?
Hi Luke, With 5000 numbers I got the numbers below with a slightly modified benchmark. If one method generates garbage and triggers a garbage collection while running the following method, then the numbers will be unfair. To avoid this I call collect-garbage before calling time. map-once method number 1: cpu time: 2832 real time: 3406 gc time: 1970 cpu time: 1895 real time: 1973 gc time: 1472 cpu time: 1941 real time: 2070 gc time: 1514 map-once method number 2: cpu time: 2212 real time: 2288 gc time: 1687 cpu time: 2320 real time: 2395 gc time: 1766 cpu time: 2344 real time: 2451 gc time: 1815 map-once method number 3: cpu time: 12547 real time: 13146 gc time: 11738 cpu time: 10687 real time: 10824 gc time: 9930 cpu time: 10615 real time: 10786 gc time: 9860 map-once method number 4: cpu time: 1718 real time: 1795 gc time: 1379 cpu time: 1796 real time: 1827 gc time: 1403 cpu time: 1751 real time: 1816 gc time: 1380 map-once method number 5: cpu time: 1311 real time: 1381 gc time: 1081 cpu time: 1346 real time: 1401 gc time: 1119 cpu time: 1375 real time: 1491 gc time: 1129 vector method: cpu time: 1063 real time: 1154 gc time: 365 cpu time: 942 real time: 1024 gc time: 366 cpu time: 921 real time: 1002 gc time: 391 #lang racket ; testing for post on racket mailing list ; https://groups.google.com/forum/#!topic/racket-users/7lkOjjpVa6A ;; Luke (define (map-once/1 f ls) (let M ([sooner null] [later ls]) (if (null? later) null (cons (append sooner (list (f (car later))) (cdr later)) (M (append sooner (list (car later))) (cdr later)) (define (list-set ls i new-val) (let-values ([(sooner later) (split-at ls i)]) (append sooner (list new-val) (cdr later (define (map-once/2 f ls) (for/list ([i (in-naturals)] [elm (in-list ls)]) (list-set ls i (f elm ;; Jon (define (map-once/3 fn xs) (for/list ([i (in-range (length xs))]) (for/list ([(x j) (in-indexed (in-list xs))]) (cond [(= i j) (fn x)] [else x] (define (map-once/v fn xs) (build-vector (vector-length xs) (λ (i) (define v (vector-copy xs)) (vector-set! v i (fn (vector-ref v i))) v))) ;; Jens (define (list-splits xs) (define (loop ys zs) ; xs = (append (reverse ys) yz) (match zs ['() '()] [(cons z zs*) (cons (list ys zs) (loop (cons z ys) zs*))])) (loop '() xs)) (define (map-once/4 f xs) (for/list ([ys+zs (list-splits xs)]) (match ys+zs [(list ys '()) '()] [(list ys (cons z zs)) (append (reverse ys) (cons (f z) zs))]))) (require (only-in srfi/1 append-reverse)) (define (map-once/5 f xs) (for/list ([ys+zs (list-splits xs)]) (match ys+zs [(list ys '()) '()] [(list ys (cons z zs)) (append-reverse ys (cons (f z) zs))]))) ;;; actual testing (define num-test-cases 5000) (define num-runs-per-f 3) (define ls (for/list ([__ (in-range num-test-cases)]) (random))) (define normal-map-onces (list map-once/1 map-once/2 map-once/3 map-once/4 map-once/5)) (for ([map-once (in-list normal-map-onces)] [i (in-naturals)]) (printf \n\nmap-once method number ~a:\n (+ i 1)) (for ([__ (in-range num-runs-per-f)]) (collect-garbage) (collect-garbage) (collect-garbage) (time (void (map-once sqr ls) (define v (for/vector ([__ (in-range num-test-cases)]) (random))) (printf \n\nvector method:\n) (for ([__ (in-range num-runs-per-f)]) (collect-garbage) (collect-garbage) (collect-garbage) (time (void (map-once/v sqr v 2015-06-19 23:08 GMT+02:00 Luke Miles rashreportl...@gmail.com: My 1000 numbers were so small that they weren't reliable. Change the `num-runs-per-f` and experiment yourself, if you'd like. The code is attached. -- 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. -- -- Jens Axel Søgaard -- 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] Macro-introducing macros with inter-macro communication channel
Probably you don't want to work with namespaces, which are intended more for run-time reflection. For an example of turning internal definitions into 'letrec-syntaxes+values', try the implementation of 'racket/block'. On Jun 23, 2015, at 10:06 AM, Thomas Dickerson thomas_dicker...@brown.edu wrote: Update / addendum: I was also able to fairly trivially extend Alex's code using let-syntax to have the more hygienic behavior for where Accum is/is-not visible, but let-syntax ends up leaving an additional layer of empty (let-values() ...) behind. The documentation for let-syntax makes the following claim - The evaluation of each trans-expr is parameterized to set current-namespace to a namespace that shares bindings and variables with the namespace being used to expand the let-syntax form, except that its base phase is one greater. which seems very much related to what I'd like to accomplish (and Shriram's suggestion that I mentioned in the original post); however, I see no evidence of this actually taking place in the Racket source-code, it just appears to desugar, with very few bells and whistles, to letrec-syntaxes+values which evidently is implemented in the C code. Digging into syntax-parameterize shows that, unsurprisingly, this is also how syntax-parameterize gets desugared, with a few more bells and whistles. So I guess at this point the remainder of my question boils down to this: can someone offer any insight into the process of turning macros which are introduced by let-syntax or equivalent into macros which are introduced implicitly by an internal-definition-context argument to local-expand, or by explicit namespace manipulation as hinted at in the let-syntax documentation (but which I can't turn up anywhere). On Monday, June 22, 2015 at 5:35:50 PM UTC-4, Thomas Dickerson wrote: Thanks for the effort that went into figuring that out! A couple first thoughts on the implementation: To first order, this is exactly what I want to be able to do (and it elegantly avoids local-expand by reasoning about expansion order); however, as a general pattern, it's a bit unhygienic in that Accum is now in the global namespace, which precludes using it as a child macro for other constructs, and prevents specific instantiations of Loop from requesting a different name for Accum to cooperate in nested loops. I also noticed that (syntax-parameterize) isn't totally transparent in the expanded syntax - it leaves a bunch of empty (let-values () ...) behind, which is fine for Racket, but problematic in my target use-case of emitting something which ultimately needs to be an entirely different language. This is why my experiments have all involved local-expand - I want to introduce expand-time names without introducing wrapping let-syntaxes (or similar) forms around my body code. On Saturday, June 20, 2015 at 2:24:40 PM UTC-4, Alex Knauth wrote: On Jun 19, 2015, at 7:44 PM, Thomas Dickerson thomas_dicker...@brown.edu wrote: I was intending for that example to have the variables be defined outside the macro, but being able to create the (set! ...) forms outside should mean I could also hypothetically create let/define-values forms. This is why I originally specified being able to effect generation of both prologue + epilogue code. I figured this out for code that will be expanded after the body: #lang racket/base (require racket/stxparam (for-syntax racket/base syntax/parse racket/set )) ;; (syntax-parameter-value vars) : (U #f (MutableSetof Identifier)) (define-syntax-parameter vars #f) (define-syntax Accum (lambda (stx) (syntax-parse stx [(Accum x:id dx:expr) (define vs (syntax-parameter-value #'vars)) (unless (set-mutable? vs) (raise-syntax-error #f cannot be used outside Loop stx)) (set-add! vs (syntax-local-introduce #'x)) #'(set! x (+ x dx))]))) (define-syntax set-accums-zero! (syntax-parser [(set-accums-zero!) #:with [x ...] (map syntax-local-introduce (set-list (syntax-parameter-value #'vars))) #'(begin (set! x 0) ...)])) (define-syntax Loop (syntax-parser [(Loop up-to-expr:expr body:expr ...+) #'(syntax-parameterize ([vars (mutable-set)]) (let ([up-to up-to-expr]) (letrec ([loop (lambda (n) body ... (if ( n up-to) (loop (add1 n)) (void)))]) (set-accums-zero!) (loop 0])) (let ([x x] [y y] [z z]) (Loop 10 (begin (define-values [dx dy dz] (values 1 2 3)) (printf x = ~v, y = ~v, z = ~v\n x y z) (Accum x dx) (Accum y dy) (Accum z dz To generate a let outside of that you’d
Re: [racket-users] Macro-introducing macros with inter-macro communication channel
Update / addendum: I was also able to fairly trivially extend Alex's code using let-syntax to have the more hygienic behavior for where Accum is/is-not visible, but let-syntax ends up leaving an additional layer of empty (let-values() ...) behind. The documentation for let-syntax makes the following claim - The evaluation of each trans-expr is parameterized to set current-namespace to a namespace that shares bindings and variables with the namespace being used to expand the let-syntax form, except that its base phase is one greater. which seems very much related to what I'd like to accomplish (and Shriram's suggestion that I mentioned in the original post); however, I see no evidence of this actually taking place in the Racket source-code, it just appears to desugar, with very few bells and whistles, to letrec-syntaxes+values which evidently is implemented in the C code. Digging into syntax-parameterize shows that, unsurprisingly, this is also how syntax-parameterize gets desugared, with a few more bells and whistles. So I guess at this point the remainder of my question boils down to this: can someone offer any insight into the process of turning macros which are introduced by let-syntax or equivalent into macros which are introduced implicitly by an internal-definition-context argument to local-expand, or by explicit namespace manipulation as hinted at in the let-syntax documentation (but which I can't turn up anywhere). On Monday, June 22, 2015 at 5:35:50 PM UTC-4, Thomas Dickerson wrote: Thanks for the effort that went into figuring that out! A couple first thoughts on the implementation: To first order, this is exactly what I want to be able to do (and it elegantly avoids local-expand by reasoning about expansion order); however, as a general pattern, it's a bit unhygienic in that Accum is now in the global namespace, which precludes using it as a child macro for other constructs, and prevents specific instantiations of Loop from requesting a different name for Accum to cooperate in nested loops. I also noticed that (syntax-parameterize) isn't totally transparent in the expanded syntax - it leaves a bunch of empty (let-values () ...) behind, which is fine for Racket, but problematic in my target use-case of emitting something which ultimately needs to be an entirely different language. This is why my experiments have all involved local-expand - I want to introduce expand-time names without introducing wrapping let-syntaxes (or similar) forms around my body code. On Saturday, June 20, 2015 at 2:24:40 PM UTC-4, Alex Knauth wrote: On Jun 19, 2015, at 7:44 PM, Thomas Dickerson thomas_dicker...@brown.edu wrote: I was intending for that example to have the variables be defined outside the macro, but being able to create the (set! ...) forms outside should mean I could also hypothetically create let/define-values forms. This is why I originally specified being able to effect generation of both prologue + epilogue code. I figured this out for code that will be expanded after the body: #lang racket/base (require racket/stxparam (for-syntax racket/base syntax/parse racket/set )) ;; (syntax-parameter-value vars) : (U #f (MutableSetof Identifier)) (define-syntax-parameter vars #f) (define-syntax Accum (lambda (stx) (syntax-parse stx [(Accum x:id dx:expr) (define vs (syntax-parameter-value #'vars)) (unless (set-mutable? vs) (raise-syntax-error #f cannot be used outside Loop stx)) (set-add! vs (syntax-local-introduce #'x)) #'(set! x (+ x dx))]))) (define-syntax set-accums-zero! (syntax-parser [(set-accums-zero!) #:with [x ...] (map syntax-local-introduce (set-list (syntax-parameter-value #'vars))) #'(begin (set! x 0) ...)])) (define-syntax Loop (syntax-parser [(Loop up-to-expr:expr body:expr ...+) #'(syntax-parameterize ([vars (mutable-set)]) (let ([up-to up-to-expr]) (letrec ([loop (lambda (n) body ... (if ( n up-to) (loop (add1 n)) (void)))]) (set-accums-zero!) (loop 0])) (let ([x x] [y y] [z z]) (Loop 10 (begin (define-values [dx dy dz] (values 1 2 3)) (printf x = ~v, y = ~v, z = ~v\n x y z) (Accum x dx) (Accum y dy) (Accum z dz To generate a let outside of that you’d probably need to do some kind of local-expand, but I’m not sure. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving
Re: [racket-users] try a new macro expander
At Thu, 21 May 2015 07:15:14 -0600, Matthew Flatt wrote: Otherwise, be prepared for me to come back in a few weeks and lobby for moving to a new macro expander. Here's the proposal: let's switch on July 16. Switch means that I'd merge the new macro expander to the master branch of the development repository. Thanks to those who have tried the new expander and reported back! Meanwhile, I've expanded the write-up and filled out the formal model (at the same URL as before). -- 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] Re: Converting a heterogenous list into a string
I reckon, rather than using match or first second (apply ~a (map (λ (x) (apply format [~a=~a] x)) paired-list)) is quite neat. BTW: In DrRacket you can get the λ by using Cmd+\ (on Mac, shortcut listed in the Insert file menu). Dan -- 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.