[racket] Is this a good design
>> A couple of comments:
>>
>> * `string-first` (- instead of the _) is a more idiomatic naming
Oke, changed that.
>> * (eq? (string? s) true) is >> verbose. (string? s) already returns
a boolean.
I changed that , thanks for the tip.
* Generally, when writing programs using the design recipe you don't
need to think of the error cases (e.g., when the contract is violated)
like `s` not being a string. You may want to think of some edge cases
though (how long can a string be?).
I know I can check on empty strings but the exercise says that I don't
have to consider empty strings.
That's why I did not check on that.
With all the remarks I changed the function to this :
;String -> String
;This function takes out the first character of a given string with
the name s
; given "roelof" expect "r"
; given "example" expect "e"
(define (string-first s)
(if (string? s)
(string-ith s 0 )
"You have not entered a string"))
Roelof