Hi Ken, string-prefix? does exactly what you want. > (define a "this") (define b "that") (define c "thisandthat") > (string-prefix? c a) #t > (string-prefix? c b) #f
https://docs.racket-lang.org/reference/strings.html#%28def._%28%28lib._racket%2Fstring..rkt%29._string-prefix~3f%29%29 Best, Shu-Hung On Friday, October 28, 2016 at 11:19:26 AM UTC-5, Ken MacKenzie wrote: > I have two things I am trying to compare, both strings. > > What I want to know is if string a is the beginning of string b. > > Example (pseudo code) > > string a = this > string b = that > string c = thisandthat > > a... == c #t > b... == c #f > > Hope I am making sense here. I couldn't figure out a way so at present my > program does this > > (define alen (length astr)) > (define bpart (substring bstr 0 alen)) > (cond > [(string=? astr bpart) #t] > [else #f]) > > That is working, but it seems like there should be a simpler solution to this. > > Ken -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.