Re: [racket] DrRacket problems, please help (I need it for homework)!
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07-02-12 07:41, enzimmer...@frontier.com wrote: Recently I've been having trouble with the DrRacket executable hanging. When I attempt to launch it, the window will pop up, the menu bar will display...and then nothing else happens - except devouring my computer's CPU like crazy. The icon at the bottom right corner shows that it's trying to load, but for whatever reason can't complete it. I decided to try and reinstall the program (several times) but the same thing happens each time I try launching the executable. I even tried re-downloading...and got the same results. Please help? It's not my computer either, because it functions beautifully and other programs work just fine on it. Hi, what version of racket and what kind of computer/OS are you using? When did DrRacket start acting out? Do you remember upgrading anything before this happened? Marijn -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.18 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk8w5GcACgkQp/VmCx0OL2xzqwCfY7RK06SHYXQcpJTyhHKRy3LF Y5EAoIyCFpdM/DEXq/prI+JAQgiqbTd3 =z/G3 -END PGP SIGNATURE- Racket Users list: http://lists.racket-lang.org/users
Re: [racket] DrRacket problems, please help (I need it for homework)!
Is this a windows machine? Assuming so, if you start DrRacket from a windows command.com shell window and then, after it gets busy hit control-c, do you get any output in the shell window? Robby On Tue, Feb 7, 2012 at 12:41 AM, enzimmer...@frontier.com wrote: Recently I've been having trouble with the DrRacket executable hanging. When I attempt to launch it, the window will pop up, the menu bar will display...and then nothing else happens - except devouring my computer's CPU like crazy. The icon at the bottom right corner shows that it's trying to load, but for whatever reason can't complete it. I decided to try and reinstall the program (several times) but the same thing happens each time I try launching the executable. I even tried re-downloading...and got the same results. Please help? It's not my computer either, because it functions beautifully and other programs work just fine on it. Racket Users list: http://lists.racket-lang.org/users Racket Users list: http://lists.racket-lang.org/users
[racket] racket in the cloud
Hi, Does anyone know if racket can be deployed in the cloud? (Is there a cloud service that support racket?). And if yes, how? :) Thanks, Razvan Racket Users list: http://lists.racket-lang.org/users
Re: [racket] racket in the cloud
There are many things that might be meant by the cloud, but on the simplest interpretation, the answer is definitely yes. For example, Eric Hanchrow (offby1) run the irc bot rudybot [1] from an Amazon EC2 Linux image. There are also two Racket bindings to the AWS service api, in various states of completeness: https://github.com/RayRacine/knozamalib/tree/master/src/racket/aws https://github.com/offby1/doodles/tree/master/plt-scheme/web/amazon (currently 404 -- does anyone know the new location?) [1] https://github.com/offby1/rudybot/ On Tue, Feb 7, 2012 at 5:16 AM, Răzvan Rotaru razvan.rot...@gmail.com wrote: Hi, Does anyone know if racket can be deployed in the cloud? (Is there a cloud service that support racket?). And if yes, how? :) Thanks, Razvan Racket Users list: http://lists.racket-lang.org/users -- sam th sa...@ccs.neu.edu Racket Users list: http://lists.racket-lang.org/users
Re: [racket] comparing structure types through contracts
Would a structure type property be a viable alternative? Example: ;; #lang racket/load (module a racket (define-values (prop:S S? S-ref) (make-struct-type-property 'S)) (provide S?) (define-struct s (a b) #:transparent #:property prop:S #t) (provide/contract [struct s ([a number?] [b number?])])) (module b racket (require 'a) (define a-struct (make-s 3 4)) (define-values (type _) (struct-info a-struct)) (printf type: ~s\n type) (printf S?: ~s\n (S? (make-s 3 4))) (printf eq? ~s\n (eq? type struct:s))) (require 'b) ;; Racket Users list: http://lists.racket-lang.org/users
Re: [racket] comparing structure types through contracts
That's a bug. I've looked into it a little bit, enough to say that I can't fix it this morning. Sorry. Robby On Tue, Feb 7, 2012 at 1:19 AM, John Clements cleme...@brinckerhoff.org wrote: I'm working with Dave Herman's JavaScript package. I've found a problem and a workaround, but I want to make sure there's not an easier workaround before I convert a bunch of code. The following program illustrates the issue: #lang racket/load (module a racket ;; this formulation works (prints #t): (define-struct/contract s ((a number?) (b number?)) #:transparent) (provide (struct-out s)) ;; this formulation does not work (prints #f): #;(define-struct s (a b) #:transparent) #;(provide/contract [struct s ([a number?] [b number?])] #;(struct-out s))) (module b racket (require 'a) (define-values (type _) (struct-info (make-s 3 4))) (printf type: ~s\n type) (printf eq? ~s\n (eq? type struct:s))) (require 'b) The problem is that when a structure is defined using define-struct and then a contract is provided at the boundary, the structure type returned by struct-info doesn't compare to the exported struct's value using eq?. As the code illustrates, I can work around this by pushing the contract down into the definition of the structure itself. Before I change many pairs of structure-definitions contracts, is there some other simpler way to make this code work--that is, print #t? Thanks! John Racket Users list: http://lists.racket-lang.org/users Racket Users list: http://lists.racket-lang.org/users
[racket] Change DrRacket autosave/backup file locations?
Hi all, Is it possible, via .racketrc, preferences, or some other mechanism, to change where DrRacket saves backup and preference files? Reason: Using DrRacket to edit programs stored in Dropbox, the presence of such temp files in my Dropbox folder is introducing a lot of noise in the Dropbox activity log. (I know, I know, I can use git or another version control system...but for the very short coding projects I usually do, that seems like overkill, really.) Best, Jordan Racket Users list: http://lists.racket-lang.org/users
Re: [racket] racket in the cloud
https://github.com/offby1/doodles/tree/master/plt-scheme/web/amazon (currently 404 -- does anyone know the new location?) It should now be visible at that URL; I'd made that repo private for no particularly good reason, and have now re-published it. Racket Users list: http://lists.racket-lang.org/users
Re: [racket] plot3d canvas question
I made a plot-canvas% class that I use. The new plot package made it pretty easy. But it doesn't support the rotation, etc functionality from the snip. It does, however, support printing which is nice. On Monday, February 6, 2012, Neil Toronto neil.toro...@gmail.com wrote: Yes, because a plot is a snip%. It's easy to do something quick and dirty. But doing it right takes more than just a few object creations and method calls. You also need to disable edit operations, hide the caret, etc., without disabling the editor itself. If it's disabled entirely, it won't receive mouse events. So it's... easy, but not entirely straightforward? That's probably the best description, and also why it might be a good idea for me to add `plot-canvas' and `plot3d-canvas' functions, or a plot-canvas% class. Neil ⊥ On 02/06/2012 06:48 PM, Robby Findler wrote: Just to be sure I'm understanding: you can put this into any GUI where you can put an editor-canvas% object, right? So it should just be a couple of object creations and method calls to get this going? Robby On Mon, Feb 6, 2012 at 5:41 PM, Neil Torontoneil.toro...@gmail.com wrote: On 02/06/2012 04:14 AM, Nikolaus Klepp wrote: Hi! When I create a 3D plot in DrRacket, I can rotate the plot by clicking on it and dragging the mouse. Now I would like to embed the same plot with the same ability in my GUI. Is there an easy way to do that? Great idea! Unfortunately, I didn't think of making an easy way to do it. Fortunately, `plot' already does something similar: if you set (plot-new-window? #t), plots appear on a canvas in a new frame. You just need to do that without the frame. The relevant code is in racket-dir/collects/plot/common/gui.rkt, specifically the `make-snip-frame' function. The basic idea is to make a canvas containing a single read-only-text% that is initially writable, insert the snip (which you get from `plot-snip' or `plot3d-snip'), and then set the text to read-only. If you want to change the plot, set the text writable, delete the snip, insert the new one, and set it read-only again. If you don't mind my asking, what are you plotting in your gui? Neil ⊥ Racket Users list: http://lists.racket-lang.org/users Racket Users list: http://lists.racket-lang.org/users Racket Users list: http://lists.racket-lang.org/users
Re: [racket] sync on OS semaphore on Unix
On 07.02.2012, at 00:35, Matthew Flatt wrote: While calling most scheme_...() function is out, can the real-time thread call scheme_signal_received(), which amounts to a write() on an native OS pipe? Unfortunately not. On Linux, this would work well, because the footprint of a write() to a pipe is very small, but on QNX, where we especially have the demand for threads running in hard realtime (jitter 10us), definitely not: as a micro-kernel OS, QNX implements pipes as a separate process, so writing to a pipe means scheduling to another process with its problems like scheduling jitter and priority inheritance ... But, a while ago you had conservation with John Clement about the mzrt_sema_post call (which seem internally be realized using condition variables and, hence, be OK on QNX). Might this call be a way to wake up the racket main thread instead of scheme_signal_received()? If not, I think we'll need a new OS thread at some level to convert a semaphore wait to a call to scheme_signal_received(). The main Racket thread on a Unix platform sleeps via epoll(), poll(), or select(), all of which need file-descriptor activity to wake up (I think). If mzrt_sema_post is no alternative, I will have to add one additional OS thread, which is waked up by, e.g., a condition variable and then polls all OS semaphores for all communications of the C threads with the racket main thread. This way, only one OS thread is enough (and not one for each semaphore as I thought yesterday). At Tue, 7 Feb 2012 00:11:51 +0100, Berthold Baeuml wrote: Is there a canonical way to make a native OS semaphore (Unix), set from an OS thread, into a racket syncable event? The use case I have in mind is a racket program which starts a native OS thread for realtime execution of a C loop. This OS thread sets a OS semaphore to signal that some data is ready for being taken by the racket side. A racket thread should now be able to somehow sync on this OS semaphore. Important fact is that the OS thread has to fulfill (hard) realtime constraints and, hence, is not allowed to call any scheme_... functions of the racket C-API with non-deterministic execution time. Moreover, I do not want to have an additional OS thread (with non-realtime constraints, then) for translating the event to the racket side, because this will give a lot of thread clutter, e.g. in with the ps command. A perfect solution would be to do it completely with the ffi-module and not having to fall back to the racket C-API. All the best, Berthold Racket Users list: http://lists.racket-lang.org/users Racket Users list: http://lists.racket-lang.org/users
Re: [racket] plot3d canvas question
Am Dienstag, 7. Februar 2012 schrieb Neil Toronto: The relevant code is in racket-dir/collects/plot/common/gui.rkt, specifically the `make-snip-frame' function. The basic idea is to make a canvas containing a single read-only-text% that is initially writable, insert the snip (which you get from `plot-snip' or `plot3d-snip'), and then set the text to read-only. If you want to change the plot, set the text writable, delete the snip, insert the new one, and set it read-only again. Hi! Ok, that worked quite straight forward, thank you. Now my next problem is how to change the size of the sniplet... If you don't mind my asking, what are you plotting in your gui? It's a visualisation of time series of 2D density distribution. Basicly it looks like a lot of slices through a trunc :-) Nik Racket Users list: http://lists.racket-lang.org/users
Re: [racket] sync on OS semaphore on Unix
At Tue, 7 Feb 2012 23:07:15 +0100, Berthold Baeuml wrote: On 07.02.2012, at 00:35, Matthew Flatt wrote: While calling most scheme_...() function is out, can the real-time thread call scheme_signal_received(), which amounts to a write() on an native OS pipe? Unfortunately not. Ok. But, a while ago you had conservation with John Clement about the mzrt_sema_post call (which seem internally be realized using condition variables and, hence, be OK on QNX). Might this call be a way to wake up the racket main thread instead of scheme_signal_received()? No. The mzrt_sema_post() function could be used to notify an OS thread that is waiting on a semaphore, but it won't work the other way around. The problem is that the main Racket thread cannot (as far as I know) wait on both a semaphore and a set of file descriptors. If not, I think we'll need a new OS thread at some level to convert a semaphore wait to a call to scheme_signal_received(). The main Racket thread on a Unix platform sleeps via epoll(), poll(), or select(), all of which need file-descriptor activity to wake up (I think). If mzrt_sema_post is no alternative, I will have to add one additional OS thread, which is waked up by, e.g., a condition variable and then polls all OS semaphores for all communications of the C threads with the racket main thread. This way, only one OS thread is enough (and not one for each semaphore as I thought yesterday). Yes, that sounds like the right idea. The one new thread will have to wake up the Racket thread using scheme_signal_received(). Then, the polling of semaphores could happen on the Racket side. For an example of how to turn a poll into a synchronizable event, see collects/mred/private/wx/common/queue.rkt around line 70. The key ingredients are 1. Allocate a new type tag at the C level via scheme_make_type(). 2. Use scheme_add_evt() to register the tag as a synchronizable event, supplying a polling callback function. (You won't need a wakeup function.) Be sure to use `#:atomic? #t' in the type for the polling callback. Racket Users list: http://lists.racket-lang.org/users
[racket] Ensuring data fed to web-server/templates is textual
Hi all, I'm using web-server/templates to generate text, and the data in variables I reference in the template include s-exps that may, in some cases, contain image% objects. I want it to render the image%s as plain text; even just the string IMAGE or similar would be adequate. So, my question is: how (via the template system or other libraries) can I best make racket perform this translation, ideally without writing code to walk the s-exp trees? It seems there must be a way someplace to tweak the output function used by the template library, but I don't know where that would be. Best, Jordan Racket Users list: http://lists.racket-lang.org/users
Re: [racket] Ensuring data fed to web-server/templates is textual
Jordan Johnson wrote at 02/07/2012 06:50 PM: I'm using web-server/templates to generate text, and the data in variables I reference in the template include s-exps that may, in some cases, contain image% objects. I want it to render the image%s as plain text; even just the string IMAGE or similar would be adequate. I don't know about web-server/templates, but if you want to do this translation at the last minute, rather than simply avoiding putting invalid values in the s-expression in the first place, another library will do it: #lang racket/base (require (planet neil/html-writing:1:0)) (define-struct some-image-thing (x)) (define (my-html-writing-filter context thing) (cond ((some-image-thing? thing) (format IMAGE ~S (some-image-thing-x thing))) (else (error 'my-html-writing-filter Don't know how to filter ~S in context ~S thing context (write-html `(html (head (title My Title)) (body (@ (bgcolor white)) (h1 My Heading) (p This is a paragraph.) (p This is a foreign thing: ,(make-some-image-thing 42)) (p This is another paragraph.))) (current-output-port) my-html-writing-filter) This writes the output: htmlheadtitleMy Title/title/headbody bgcolor=whiteh1My Heading/h1pThis is a paragraph./ppThis is a foreign thing: lt;IMAGE 42gt;/ppThis is another paragraph./p/body/html I originally implemented that feature 7 years ago, for last-minute translation of URI objects -- to output URLs as relative to the URL of the HTML object being written, rather than absolute. -- http://www.neilvandyke.org/ Racket Users list: http://lists.racket-lang.org/users
[racket] Why no string function to replace substring based on content in Racket
I wasn't able to find in the Racket documentation a string function that replaces substrings in a string based on the content of the substring. Something similar to Python's string replace method . s = abcdefabcdef s.replace(abc 123) - 123def123def But more surprising, I also wasn't able to find such a function in SRFI13 which is supposed to be a comprehensive set of operations on strings. Its string-replace function is based on position not on content of the substring. Is there some functional programming reason for not having such a built-in function in Racket/Scheme, or is the idea that you use regular expressions to do this. My understanding is that regular expressions can be quite expensive. I have Python programs which convert Indian language book length etexts from one transliteration scheme to another so I'm calling the Python replace function hundreds of thousands of times per e-text and doing multiple replaces with each call. I'd like to convert these programs to Racket, but using regular expressions might be too slow. Is writing a C foreign function. extension my only alternative or is there such a function in some Racket package.. Thanks, Harry Spier Racket Users list: http://lists.racket-lang.org/users
Re: [racket] Why no string function to replace substring based on content in Racket
Harry Spier wrote at 02/07/2012 08:05 PM: I have Python programs which convert Indian language book length etexts from one transliteration scheme to another so I'm calling the Python replace function hundreds of thousands of times per e-text and doing multiple replaces with each call. What about doing all these substitutions in a single pass of reading the input? You could do it by hand, using reading primitives and/or perhaps using regexps just to tokenize. Or you could try using the regexp engine more, perhaps by programmatically assembling a single regexp that matches any of your terms to replace, and then doing a table lookup to find the substitution. I'd like to convert these programs to Racket, but using regular expressions might be too slow. Is writing a C foreign function. extension my only alternative or is there such a function in some Racket package.. A clever implementation in pure Racket code might be faster than a less-clever implementation in C. -- http://www.neilvandyke.org/ Racket Users list: http://lists.racket-lang.org/users
Re: [racket] Why no string function to replace substring based on content in Racket
On Tue, Feb 7, 2012 at 8:05 PM, Harry Spier vasishtha.sp...@gmail.com wrote: I'd like to convert these programs to Racket, but using regular expressions might be too slow. I find that my intuitions about what might or might not be too slow are usually wrong. Have you tried measuring this? -- sam th sa...@ccs.neu.edu Racket Users list: http://lists.racket-lang.org/users
Re: [racket] Why no string function to replace substring based on content in Racket
1. I am surprised that regexp-replace* does not work on input-ports like all other regexp- functions. I assume Matthew has a rationale but my quick look didn't discover it in the docs. 2. I ran this stupid little program below. The timing for a file of 19990186 chars over 9896 lines, with 9922 occurrences of abc clocks in like this: cpu time: 4570 real time: 4629 gc time: 2164 How much too slow is this? -- Matthias #lang typed/racket (define file /tmp/test.txt) #; (with-output-to-file file #:exists 'replace (lambda () (for: ((i (in-range 1000))) (define r (random 1000)) (cond [(= r 13) (display abc)] [(= r 27) (newline)] [else (display de)] (: f (- (Listof String))) (define (f) (define next (read-line)) (if (eof-object? next) '() (cons (regexp-replace* next abc xy) (f (collect-garbage) (collect-garbage) (collect-garbage) (define x (time (with-input-from-file file f))) On Feb 7, 2012, at 8:05 PM, Harry Spier wrote: I wasn't able to find in the Racket documentation a string function that replaces substrings in a string based on the content of the substring. Something similar to Python's string replace method . s = abcdefabcdef s.replace(abc 123) - 123def123def But more surprising, I also wasn't able to find such a function in SRFI13 which is supposed to be a comprehensive set of operations on strings. Its string-replace function is based on position not on content of the substring. Is there some functional programming reason for not having such a built-in function in Racket/Scheme, or is the idea that you use regular expressions to do this. My understanding is that regular expressions can be quite expensive. I have Python programs which convert Indian language book length etexts from one transliteration scheme to another so I'm calling the Python replace function hundreds of thousands of times per e-text and doing multiple replaces with each call. I'd like to convert these programs to Racket, but using regular expressions might be too slow. Is writing a C foreign function. extension my only alternative or is there such a function in some Racket package.. Thanks, Harry Spier Racket Users list: http://lists.racket-lang.org/users Racket Users list: http://lists.racket-lang.org/users
[racket] Program runs fine in console , but not in drracket.
I just recently downloaded racket version 5.2.1. Now when running a particular program in drracket I get following error : compile: unbound identifier in the transformer environment (and no #%app syntax transformer is bound) in: #%require But when same program is run in console , it works just fine . Other programs that does not require this program , works just fine in drracket. Any idea how to resolve this. Thanks Racket Users list: http://lists.racket-lang.org/users