fork download
  1. ; first word
  2.  
  3. (define (string-index c str)
  4. (let loop ((ss (string->list str)) (k 0))
  5. (cond ((null? ss) #f)
  6. ((char=? (car ss) c) k)
  7. (else (loop (cdr ss) (+ k 1))))))
  8.  
  9. (define (first-word str)
  10. (substring str 0 (string-index #\space str)))
  11.  
  12. (display (first-word "abcdefg hijklmnop qrs tuv wxyz"))
Success #stdin #stdout 0.01s 50288KB
stdin
Standard input is empty
stdout
abcdefg