cl:string-find-char   scheme


Defined in:  https://github.com/lambdamusic/extempore-extensions/blob/main/init/init_lisp.xtm

Implementation

;; works only with single chars for now
;; return the position of a char in a string
(define cl:string-find-char 
   (lambda (z singlechar)
      (if (> (string-length singlechar) 1)
          (print "can't match strings longer than 1 char")
          (let p ((x 1))
             (let ((l (string->list z)))
                (if (equal? (cl:nth x l) (cl:char singlechar))
                    x
                    (if (< x (length l))
                        (p (+ x 1))
                        #f)))))))


Back to Index