[racket] Is this a good design

From: Roelof Wobben (r.wobben at home.nl)
Date: Fri Mar 2 04:44:36 EST 2012

Op 2-3-2012 9:51, Danny Yoo schreef:
>
> > I did some study on that chapter but I cannnot make it work,
> > This is what I have so  far :
> >
> > ;;String -> String
> > ;; Get the first character of a string (s) if there is one. error 
> otherwise.
> > ;; given "aaaa" expected "a"
> > ;; given "" expected "
> > (define (first-string s)
> >  (cond
> >    [(eq? s "") (error "first-string" "Empty string found")]    ;; 
> check for a empty string.if so put a error message
> >    [(and (string? s) (not(eq? s "")))  (string-ith s 0)]             
>  ;; if it's a non-empty string then do the trick.
> >    [(number? s) (error "first-string" "No string found")]      ;; if 
> it's a number then put a error message
> >    [(boolean? s) (error "first-string" "No string found")]     ;; if 
> it's a boolean then put a error message
> >    [(image? s) (error "first string" "No string found")]         ;; 
> if it's a image put a error message
> >    ))
> >
> > But when I do (first-string ") then still DrRacket gives his own 
> error message instead of the one I made.
> > Any tips are welcome here.
>
>
> What is the exact content of the error message that DrRacket gives you? 

Very wierd.

On my windows box I see this message appear : string-ith: expected an 
exact integer in [0, length of the given string] for the second 
argument, but received 0

On my linux box it worked well and I see what I expected.

Roelof


Posted on the users mailing list.