Re: [racket] xml processing question

2010-12-22 Thread Manfred Lotz
On Wed, 22 Dec 2010 12:23:00 -0700 Jay McCarthy wrote: > (require xml) does not provide any special processing functions. You > can use normal pattern matching and functions on both the XML data > structures and the xexpr representation. I used 'match' a lot. > I see. Thanks for the information

Re: [racket] comments requested from users of SXML and PLT xexprs

2010-12-22 Thread Noel Welsh
On Tue, Dec 21, 2010 at 2:20 PM, Neil Van Dyke wrote: > > Here's a simple example, which doesn't demonstrate all the features: > >   (html-template >     (html (head (title "Foo & Bar")) >   (body (h1 (*value* essay-title)) >     (p "Bunnies are nice." (br) "Yep." > ... Lo

[racket] placing-queen 43.3.1

2010-12-22 Thread Ken Hegeland
I am just about done with the book, only a few more exercises. The method I went at for this problem was to just set the initial position to false and then recur on the interval. My thinking is, to make all the spots the queen threatens on a horizontal, you would leave the y and adjust the x.

Re: [racket] status of keyword argument support in TR?

2010-12-22 Thread Sam Tobin-Hochstadt
On Wed, Dec 22, 2010 at 9:48 PM, Neil Van Dyke wrote: > What's the status of keyword argument support in Typed Racket? The below is still the current state, unfortunately. > http://groups.google.com/group/plt-scheme/browse_thread/thread/2da648c872fc6d97 > > Sam Tobin-Hochstadt wrote at Fri, 24 S

Re: [racket] Order of Operations - Getting the brackets.

2010-12-22 Thread Sayth Renshaw
On Thu, Dec 23, 2010 at 2:26 AM, Todd O'Bryan wrote: > I just realized something. You probably speak British (or at least > un-American) English. One of my former students from Manchester said > the first two weeks of math were very confusing because what we call > parentheses he called brackets

Re: [racket] comments requested from users of SXML and PLT xexprs

2010-12-22 Thread Neil Van Dyke
Eli Barzilay wrote at 12/22/2010 08:04 PM: 6 minutes ago, Neil Van Dyke wrote: Thanks for your comments, Eli. I am still wavering on whether to do the permissive thing. And I am also looking at whether Typed Scheme and/or "html-template" make the permissiveness less useful than before.

[racket] status of keyword argument support in TR?

2010-12-22 Thread Neil Van Dyke
What's the status of keyword argument support in Typed Racket? I found the below message from three months ago, after my Racket blew up in the same way: I'll have to find a way to work around this or postpone my TR adoption, since I use keyword arguments heavily. http://groups.google.com/gr

Re: [racket] comments requested from users of SXML and PLT xexprs

2010-12-22 Thread Eli Barzilay
6 minutes ago, Neil Van Dyke wrote: > Thanks for your comments, Eli. I am still wavering on whether to do > the permissive thing. And I am also looking at whether Typed Scheme > and/or "html-template" make the permissiveness less useful than > before. Well, the problems that I ran into wouldn't

Re: [racket] comments requested from users of SXML and PLT xexprs

2010-12-22 Thread Neil Van Dyke
Thanks for your comments, Eli. I am still wavering on whether to do the permissive thing. And I am also looking at whether Typed Scheme and/or "html-template" make the permissiveness less useful than before. Permissiveness sure does make some things harder to implement and more computational

[racket] DrRacket indent of "let:"

2010-12-22 Thread Neil Van Dyke
DrRacket 5.0.2 isn't indenting Typed Racket "let:" forms idiomatically. It indents them in the default way rather than a special way like it does for Racket "let" forms. In case anyone wants to fix this, here's how Quack currently indents "let:" (leading space characters replaced here with ".

Re: [racket] comments requested from users of SXML and PLT xexprs

2010-12-22 Thread Eli Barzilay
Yesterday, Neil Van Dyke wrote: > Comments requested from anyone who has used SXML or xexprs... (I didn't use either of these to a point that I could comment, but I played with a bunch of similar things, mostly trying to get away from the problems of the latter.) > The extraneous list nesting in

Re: [racket] confusion on Typed Racket, pairs, and lists

2010-12-22 Thread Carl Eastlund
Work around this with explicit let or other intermediate bindings: Welcome to Racket v5.0.99.5. > (let: ([x : Integer 5]) (ann x Real)) - : Real 5 > (let: ([x : Real 5]) (ann x Integer)) stdin::64: Type Checker: Expected Integer, but got Real in: x Carl Eastlund On Wed, Dec 22, 2010 at 3:54 PM,

Re: [racket] confusion on Typed Racket, pairs, and lists

2010-12-22 Thread Neil Van Dyke
Thanks, I'm relieved if that's a bug. Although, if it is a bug, it's a showstopper for me until fixed, as problems like this exhibit throughout some list-processing-intensive code I'm trying to convert to Typed Racket. Carl Eastlund wrote at 12/22/2010 03:42 PM: I believe your intermediate ex

Re: [racket] confusion on Typed Racket, pairs, and lists

2010-12-22 Thread Carl Eastlund
I have just filed this as a bug report. Typed Racket appears to process nested annotations in the wrong order. Welcome to Racket v5.0.99.5. > (ann (ann 5 Real) Integer) - : Real 5 > (ann (ann 5 Integer) Real) stdin::37: Type Checker: Expected Integer, but got Real in: 5 Carl Eastlund On Wed, De

Re: [racket] confusion on Typed Racket, pairs, and lists

2010-12-22 Thread Carl Eastlund
I believe your intermediate expression there, the one with two "ann"otations in it, is a Typed Racket bug. You should definitely not be able to take something with the type (Listof Symbol) and coerce it to (List Symbol Symbol). For instance: > (: f ((Listof Symbol) -> (List Symbol Symbol))) > (d

Re: [racket] confusion on Typed Racket, pairs, and lists

2010-12-22 Thread Neil Van Dyke
Carl Eastlund wrote at 12/22/2010 03:06 PM: So each time you apply cons, if you don't want a Listof type you have to "convince" it to build something else. Do this by either annotating each step, or binding cons with a simpler type. Thanks for the explanation. I found that annotating eac

Re: [racket] equal? and objects

2010-12-22 Thread Danny Yoo
> I am trying to implement an is-equal? function like this: > >    ;; is-equal? : the-obj -> boolean >    (define/public (is-equal? another-obj) >      (andmap (λ (field-name) >                 (equal? (get-field field-name another-obj) >                         field-name)) >              (field-n

Re: [racket] xml processing question

2010-12-22 Thread Neil Van Dyke
I usually use the SXML-related tools in PLaneT, rather than the "xexpr" ones. They are a little tricky to get started with (I plan to improve this situation soon), so here is a simple demonstration using your example, to get you started: Begin Example #lang racket/base (require (o

Re: [racket] confusion on Typed Racket, pairs, and lists

2010-12-22 Thread Carl Eastlund
This works for me: > (ann (cons 'a (ann (cons 'b '()) (List Symbol))) (List Symbol Symbol)) - : (List Symbol Symbol) '(a b) As does this: > (: pair (All [X Y] (X Y -> (Pairof X Y > (define pair cons) > (pair 'a (pair 'b '())) - : (List 'a 'b) '(a b) > (ann (pair 'a (pair 'b '())) (List Symbo

[racket] confusion on Typed Racket, pairs, and lists

2010-12-22 Thread Neil Van Dyke
Any guidance on how to deal with constructing objects of list types using "cons" in Typed Scheme? Here is an illustration of one of the difficulties I'm having: trying to produce a "(List Symbol Symbol)" using "cons"... 1. Use "cons" to produces a list of one element, annotated as different

Re: [racket] xml processing question

2010-12-22 Thread Jay McCarthy
(require xml) does not provide any special processing functions. You can use normal pattern matching and functions on both the XML data structures and the xexpr representation. I used 'match' a lot. If you look on PLaneT, you will find a few processing libraries, like an XPath implementation. Jay

[racket] xml processing question

2010-12-22 Thread Manfred Lotz
Hi there, I'd like to know how to idiomatically handle xml using racket's xml. Let's assume a minimal example like this: (define xmlin " Some software ") (define xe (string->xexpr xmlin)) or (define xe (xml->xexpr (document-element (read-xml (open-input-string xmlin) Now my

Re: [racket] ":" preferred to "define:"?

2010-12-22 Thread Eli Barzilay
40 minutes ago, Sam Tobin-Hochstadt wrote: > On Wed, Dec 22, 2010 at 12:36 PM, Neil Van Dyke wrote: > > Why is ":" preferred to "define:", when usually you're just going to follow > > the ":" form with a "define" form? > > > > The Typed Racket Reference says: > > > >> In most cases, use of ":" is

Re: [racket] raise-ing an exception inside prompt

2010-12-22 Thread Sam Tobin-Hochstadt
On Wed, Dec 22, 2010 at 12:52 PM, Keiko Nakata wrote: >> The relevant docs are in raise, with-exception-handler, and >> uncaught-exception-handler. > > Can I get to know where is the source, as drracket does not navigate me? The source for `with-handlers' and `prompt' you can find by using check

Re: [racket] raise-ing an exception inside prompt

2010-12-22 Thread Robby Findler
I'm not completely sure. If drracket couldn't take me, I'd resort to grepping ... Robby On Wed, Dec 22, 2010 at 11:52 AM, Keiko Nakata wrote: > From: Robby Findler > Subject: Re: [racket] raise-ing an exception inside prompt > Date: Wed, 22 Dec 2010 11:46:49 -0600 > >> No, prompt doesn't do tha

Re: [racket] raise-ing an exception inside prompt

2010-12-22 Thread Keiko Nakata
From: Robby Findler Subject: Re: [racket] raise-ing an exception inside prompt Date: Wed, 22 Dec 2010 11:46:49 -0600 > No, prompt doesn't do that. > > This boils down to what the default uncaught-exception-handler does, which is: > > (abort-current-continuation (default-continuation-prompt-ta

Re: [racket] raise-ing an exception inside prompt

2010-12-22 Thread Robby Findler
No, prompt doesn't do that. This boils down to what the default uncaught-exception-handler does, which is: (abort-current-continuation (default-continuation-prompt-tag) void) The relevant docs are in raise, with-exception-handler, and uncaught-exception-handler. Robby On Wed, Dec 22, 2010 at

Re: [racket] ":" preferred to "define:"?

2010-12-22 Thread Sam Tobin-Hochstadt
On Wed, Dec 22, 2010 at 12:36 PM, Neil Van Dyke wrote: > Why is ":" preferred to "define:", when usually you're just going to follow > the ":" form with a "define" form? > > The Typed Racket Reference says: > >> In most cases, use of ":" is preferred to use of "define:". Two reasons: 1. Adding `

[racket] ":" preferred to "define:"?

2010-12-22 Thread Neil Van Dyke
Why is ":" preferred to "define:", when usually you're just going to follow the ":" form with a "define" form? The Typed Racket Reference says: In most cases, use of ":" is preferred to use of "define:". -- http://www.neilvandyke.org/ _ For li

Re: [racket] raise-ing an exception inside prompt

2010-12-22 Thread Carl Eastlund
It looks like prompt installs its own exception handler. So the 3 gets caught and reported by prompt, which then returns a default value of void and the call to + continues. This bears out with other examples, such as (list (prompt (raise 3))), which returns a list containing void. Carl Eastlund

Re: [racket] raise-ing an exception inside prompt

2010-12-22 Thread Matthias Felleisen
That's beyond me but displayln orders 'events' better here. On Dec 22, 2010, at 12:28 PM, Keiko Nakata wrote: > I'm not sure if I got your point, as I seem to have the same result > after replacing with displayln. > > My concern is why I get a type error only for the latter? > (And how I co

Re: [racket] raise-ing an exception inside prompt

2010-12-22 Thread Keiko Nakata
I'm not sure if I got your point, as I seem to have the same result after replacing with displayln. My concern is why I get a type error only for the latter? (And how I could get both the exception and type error?) Keiko From: Matthias Felleisen Subject: Re: [racket] raise-ing an exception i

Re: [racket] raise-ing an exception inside prompt

2010-12-22 Thread Matthias Felleisen
Replace print with displayln. (You're buffering the output but it isn't displayed until the repl prints the next prompt.) On Dec 22, 2010, at 11:56 AM, Keiko Nakata wrote: > Hello, > > How should I understand this behavior? > > (with-handlers ([(lambda (_) #t) (lambda (_) (print "exit"))])

[racket] raise-ing an exception inside prompt

2010-12-22 Thread Keiko Nakata
Hello, How should I understand this behavior? (with-handlers ([(lambda (_) #t) (lambda (_) (print "exit"))]) (print (+ (prompt (print "hi") (raise 3) (print "bye")) 10))) prints "hi" then "exit", whereas (+ (prompt (print "hi") (raise 3) (print "bye")) 10) prints "hi", then I got an uncaught

Re: [racket] Order of Operations - Getting the brackets.

2010-12-22 Thread Todd O'Bryan
I just realized something. You probably speak British (or at least un-American) English. One of my former students from Manchester said the first two weeks of math were very confusing because what we call parentheses he called brackets and what we called brackets, he called something else. Here's

Re: [racket] Order of Operations - Getting the brackets.

2010-12-22 Thread Todd O'Bryan
Here's an algorithm for converting from "normal math" to Racket. Write your expression: people * ticket-price - (number-of-shows * 20 + people * ticket-price) Notice that I didn't put parentheses anywhere that order of operations didn't require them. Now, add exactly one pair of parentheses for

Re: [racket] Basic Racket Question

2010-12-22 Thread Stephen Bloch
On Dec 21, 2010, at 5:43 PM, Sayth Renshaw wrote: > Do i need to define the gross function in my netpay function? No, you don't. You've already defined it by saying (define (gross hours) (* hours pay-rate)) > If I have defined gross function as suggested earlier why can'

Re: [racket] Basic Racket Question

2010-12-22 Thread Robby Findler
Yep. Robby On Tue, Dec 21, 2010 at 11:11 PM, Sayth Renshaw wrote: > > > On Wed, Dec 22, 2010 at 2:04 PM, Robby Findler > wrote: >> >> FWIW, if you were in my class, that solution would get few points. You >> may have noticed people asking you about the design recipe in this >> thread. That is a

[racket] Solved Re: Order of Operations - Getting the brackets.

2010-12-22 Thread sayth
Sayth Renshaw writes: > > What I am having trouble navigating is the brackets.Simply in normal math what I am trying to do is(people * ticket price)-((number of shows * 20)+(people * cost per person))Contrcat : total profit : attendees performance -> number;; Purpose to calculate total profit of

[racket] Order of Operations - Getting the brackets.

2010-12-22 Thread Sayth Renshaw
What I am having trouble navigating is the brackets. Simply in normal math what I am trying to do is (people * ticket price)-((number of shows * 20)+(people * cost per person)) Contrcat : total profit : attendees performance -> number ;; Purpose to calculate total profit of a theatre per show