[racket] regexp-replace* with input-port ==> Re: multi-replace function

2010-12-06 Thread Eli Barzilay
Two minutes ago, YC wrote: > This brings up something I noticed earlier today looking at regexp > docs: regexp-replace family does not work with input-port, when the > other regexp-* functions do. > > Are there reasons for the difference?  Is it because input-port cannot be > written to? Well, th

[racket] regexp-replace* with input-port ==> Re: multi-replace function

2010-12-06 Thread YC
On Mon, Dec 6, 2010 at 11:15 PM, Eli Barzilay wrote: > > One thing to keep in mind is that if you only care about replacing > occurrences in some input file, then you can avoid the overhead of > collecting the full text in memory. For example, this will read the > standard input, and replace eac

Re: [racket] multi-replace function

2010-12-06 Thread Eli Barzilay
15 minutes ago, YC wrote: > > On Mon, Dec 6, 2010 at 10:21 PM, prad wrote: > > i'm trying create a multi-replace function in racket where you can > substitute for patterns in a string with items in a list: > > (mult-repl "~A" >           "this ~A string will experience ~A substi

Re: [racket] multi-replace function

2010-12-06 Thread YC
On Mon, Dec 6, 2010 at 10:21 PM, prad wrote: > i'm trying create a multi-replace function in racket where you can > substitute for patterns in a string with items in a list: > > (mult-repl "~A" > "this ~A string will experience ~A substitution" > (list "wonderful" "massive"))

Re: [racket] Value Extraction from Lists vs. Structures

2010-12-06 Thread Noel Welsh
Structure access is implemented by taking the address of the structure and adding an offset giving the memory address of the field. Addition is an O(1) operation, as is memory referencing. HTH, N. PS: Neither of the above statements are completely true, but they suffice for a simple machine model

[racket] multi-replace function

2010-12-06 Thread prad
i'm trying create a multi-replace function in racket where you can substitute for patterns in a string with items in a list: (mult-repl "~A" "this ~A string will experience ~A substitution" (list "wonderful" "massive")) -> "this wonderful string will experience massive subst

[racket] Value Extraction from Lists vs. Structures

2010-12-06 Thread Luke Jordan
I'm reading HtDP 29.3. I get how value extraction from lists works in O(n) time, but how does extraction from structures work in O(1)? Thanks (for being the "help me with HtDP" mailing list as well as the Racket mailing list...) Luke _ For list-r

Re: [racket] read text file

2010-12-06 Thread Eli Barzilay
Three minutes ago, prad wrote: > On Mon, 6 Dec 2010 19:48:14 -0700 > Jay McCarthy > wrote: > > > Try file->string > > > thx jay and sam! > file->string works very nicely for what i'm doing, but i'll check the > read-all out later. interesting that now i have so many options! :D Just to give you

Re: [racket] read text file

2010-12-06 Thread prad
On Mon, 6 Dec 2010 19:48:14 -0700 Jay McCarthy wrote: > Try file->string > thx jay and sam! file->string works very nicely for what i'm doing, but i'll check the read-all out later. interesting that now i have so many options! :D -- In friendship, prad ...

Re: [racket] read text file

2010-12-06 Thread Sam Phillips
On Mon, Dec 6, 2010 at 6:52 PM, Sam Phillips wrote: > On Mon, Dec 6, 2010 at 6:43 PM, prad wrote: >> but what am i supposed to in racket? >> (other than read-line right through to the end of the file, may be?) > > In unstable/port there is read-all.  Which you could use like > > (list->string (re

Re: [racket] read text file

2010-12-06 Thread Sam Phillips
On Mon, Dec 6, 2010 at 6:43 PM, prad wrote: > but what am i supposed to in racket? > (other than read-line right through to the end of the file, may be?) In unstable/port there is read-all. Which you could use like (list->string (read-all read-char port)) Cheers, Sam __

Re: [racket] read text file

2010-12-06 Thread Jay McCarthy
Try file->string Jay On Mon, Dec 6, 2010 at 7:43 PM, prad wrote: > i'm trying to read a text file into a string, sort of like > > readFile path -- in haskell > or > handle = open(path, 'r'); data = handle.read() # in python > > however, in the guide > open-input-file > call-with-input-file > al

[racket] read text file

2010-12-06 Thread prad
i'm trying to read a text file into a string, sort of like readFile path -- in haskell or handle = open(path, 'r'); data = handle.read() # in python however, in the guide open-input-file call-with-input-file all use read-line in lisp i could get the length of the stream and slurp the whole fil

Re: [racket] Serving a static html file

2010-12-06 Thread racketusers . 20 . gilesroberts
I'm glad it is working Jay Sent from my iPhone On Dec 6, 2010, at 11:17 AM, Giles Roberts wrote: > Dear Jay, > > Thanks for letting me know I'm on the right track. I've reduced my html file > to the simplest possible and it's now producing the expected result. Must be > something within

Re: [racket] Sweet-expression support in Racket?

2010-12-06 Thread andrew cooke
Thanks. If I don't hear anything more I'll give it a go. Need to learn something new... Andrew On Mon, 6 Dec 2010 14:54:36 -0500, Carl Eastlund wrote: Andrew, I am not aware of such a language, but one could easily be written in the same vein as "#lang s-exp ", which uses the concrete s

[racket] Sweet-expression support in Racket?

2010-12-06 Thread andrew cooke
Hi, Racket appears to be carefully implemented for multiple syntaxes. Does that mean that a sweet-expression (or similar) lang or reader already exists? I have searched around, but cannot find one. Thanks, Andrew PS Sweet expressions - http://www.dwheeler.com/readable/sweet-expressions.h

Re: [racket] Serving a static html file

2010-12-06 Thread racketusers . 20 . gilesroberts
Dear Jay, Thanks for letting me know I'm on the right track. I've reduced my html file to the simplest possible and it's now producing the expected result. Must be something within the hairy beast I was initially trying to serve that was causing the upset. Regards Giles. ___

Re: [racket] Serving a static html file

2010-12-06 Thread racketusers . 20 . gilesroberts
I cannot replicate the problem. Maybe if you send me an tarball with an accurate picture of the situation I can find some subtlety. But when I use the file you've given and put some HTML file in the "htdocs" directory, I get the expected result. Jay On Sun, Dec 5, 2010 at 12:41 AM, Giles Roberts