[racket] Coerce Number to uint32

2012-06-08 Thread Vince Kuyatt
While working on the Rhipmunk FFI, I ran into a definition called "NOT_GRABABLE_MASK", which as far as I can tell, is defined as: #define GRABABLE_MASK (1<<31) #define NOT_GRABABLE_MASK (~GRABABLE_MASK) The problem with this, is that when I do the same operations: (define GRABABLE_MASK (int->uint

Re: [racket] How to not escape html entities in xexpr->string ?

2012-06-08 Thread 安龙
Thx , and that should be what I want : ) 2012/6/9 Jay McCarthy > There is no way to mark some strings as "safe". However, you can > include CDATA in an xexpr and the xml library assumes that cdata have > the cdata wrapper--- but you can just lie. > > Here is the documentation for CDATA: >

Re: [racket] How to not escape html entities in xexpr->string ?

2012-06-08 Thread Jay McCarthy
There is no way to mark some strings as "safe". However, you can include CDATA in an xexpr and the xml library assumes that cdata have the cdata wrapper--- but you can just lie. Here is the documentation for CDATA: http://docs.racket-lang.org/xml/index.html?q=cdata#(def._((lib._xml/main..rkt)

[racket] How to not escape html entities in xexpr->string ?

2012-06-08 Thread 安龙
Hi all, I use xexpr to write template, but i find "xexpr/response" will escape html entities like "<" to < . xexpr->string do this thing also, so how to mark some strings are "safe" in expr? Best wishes -- aisk Racket Users list: http://lists.racket-lang.org/use

Re: [racket] procedure contract for "at least N arguments, possibly more"

2012-06-08 Thread Robby Findler
It is kind of like you want a dependent contract: once the first function is called then it's range contract is forever fixed to some specific number of values and after that the domain of P2 is also fixed to some specific number of values. You can drop down to the low-level and write such a contr

Re: [racket] procedure contract for "at least N arguments, possibly more"

2012-06-08 Thread Neil Van Dyke
Robby Findler wrote at 06/08/2012 09:31 PM: To get a little more context: what happens if P1 returns different numbers of values each time it is called? That would be a programming error by the user of this library, and I'm fine with them getting a non-contracts runtime error. I think my

Re: [racket] procedure contract for "at least N arguments, possibly more"

2012-06-08 Thread Robby Findler
To get a little more context: what happens if P1 returns different numbers of values each time it is called? How do you know which ones match up to which calls of P2? Also, perhaps not the best thing (pending the answer above), you can write a predicate contract that gets the procedure-arity resul

[racket] procedure contract for "at least N arguments, possibly more"

2012-06-08 Thread Neil Van Dyke
Is there a way with the core procedure contractor combinators, to say "at least 2 arguments, possibly more"? So far, I have gotten "->*" to give me "2 arguments and arbitrarily more", which is not what I want. (Rationale for why I want "at least 2 arguments, possibly more"... I have a librar

Re: [racket] Scribble to latex

2012-06-08 Thread Mark Millikan
Two work arounds: 1. Launch DrRacket from a terminal with 2. Run == This fragment from racket/collects/redex/private/dot.rkt succinctly describes the problem and a hard-coded solution to the root problem: ;; these paths are explicitly checked (when find-executable-path ;

Re: [racket] Definitions in cond-bodies

2012-06-08 Thread Jens Axel Søgaard
2012/6/8 Sam Tobin-Hochstadt : > What's happening is that `#%top` behaves differently at the REPL than > in a module.  This enables you to write: > > -> (define (even? x) (or (zero? x) (odd? (sub1 x > -> (define (odd? x) (or (= x 1) (even? (sub1 x > > without getting an error when entering

Re: [racket] Definitions in cond-bodies

2012-06-08 Thread Matthias Felleisen
Ah silly me, another senior moment :-) On Jun 8, 2012, at 12:06 PM, Robby Findler wrote: > Yes, of course it is and that first branch executes and thus the error > in the second branch (now a runtime error, thanks to the repl), is not > signaled. > > Robby > > On Fri, Jun 8, 2012 at 11:01 AM

Re: [racket] Definitions in cond-bodies

2012-06-08 Thread J. Ian Johnson
Yet, the REPL allows this interaction: > (let ([x 1]) (cond [(= x 1) (define u 2) (+ u 1)] [else u])) 3 > (define (f x) (cond [(= x 1) (define u 2) (+ u 1)] [else u])) > (f 1) 3 > (f 0) reference to undefined identifier: u === context === /home/ianj/plt/pltgit/collec

Re: [racket] Definitions in cond-bodies

2012-06-08 Thread Robby Findler
Yes, of course it is and that first branch executes and thus the error in the second branch (now a runtime error, thanks to the repl), is not signaled. Robby On Fri, Jun 8, 2012 at 11:01 AM, Matthias Felleisen wrote: > > With all due respect, I disagree. Like Jens, I consider the (define u ..)

Re: [racket] Definitions in cond-bodies

2012-06-08 Thread Matthias Felleisen
With all due respect, I disagree. Like Jens, I consider the (define u ..) nested and scoped inside the first cond branch. On Jun 8, 2012, at 11:56 AM, Sam Tobin-Hochstadt wrote: > On Fri, Jun 8, 2012 at 11:42 AM, Jens Axel Søgaard > wrote: >> >> When >> >> (let ([x 1]) >> (cond >>[(=

Re: [racket] Definitions in cond-bodies

2012-06-08 Thread Sam Tobin-Hochstadt
On Fri, Jun 8, 2012 at 11:42 AM, Jens Axel Søgaard wrote: > > When > > (let ([x 1]) >  (cond >    [(= x 1) >     (define u 2) >     (+ u 1)] >    [else u])) > > is pasted into the interaction window, I get 3  ! > > I was expecting an error. This is the same behavior as: -> (if #f x 1) 1 What's

[racket] Definitions in cond-bodies

2012-06-08 Thread Jens Axel Søgaard
I have found an interesting program: #lang racket (let ([x 1])  (cond    [(= x 1)     (define u 2)     (+ u 1)]    [else u])) When run gives a very reasonable error message:     expand: unbound identifier in module in: u When (let ([x 1])  (cond    [(= x 1)     (define u 2)     (+ u 1)]    [els

Re: [racket] Replacing lambdas with defines

2012-06-08 Thread David Janke
Since the inner-most lambda block references the list ("l"), aren't the nested lambda's the cleanest implementation? Otherwise, you would have to use currying, which looks like it would add complexity (based on a random article i just found, here http://www.engr.uconn.edu/~jeffm/Papers/curry.html)

Re: [racket] Replacing lambdas with defines

2012-06-08 Thread Matthias Felleisen
On Jun 8, 2012, at 10:25 AM, Ashok Bakthavathsalam wrote: > > (define (permute l) > > > (if (null? l) > > > '(()) > > > (apply append (map (lambda (p) > > >(map (lambda (n) > > > (insert p n (car l))) > > >

[racket] Replacing lambdas with defines

2012-06-08 Thread Ashok Bakthavathsalam
Below, I have enclosed the code from Rosetta for generating Permutations. Can someone show me how to replace nested lambdas with defines? Thanks, (define (insert l n e) (if (= 0 n) (cons e l) (cons (car l) (insert (cdr l) (- n 1) e (define (seq start end) (if