string-cmp?   scheme


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/runtime/init.xtm

Implementation

; Note the trick of returning (cmp x y)
(define (string-cmp? chcmp cmp a b)
  (let ((na (string-length a)) (nb (string-length b)))
    (let loop ((i 0))
      (cond
       ((= i na)
        (if (= i nb) (cmp 0 0) (cmp 0 1)))
       ((= i nb)
        (cmp 1 0))
       ((chcmp = (string-ref a i) (string-ref b i))
        (loop (succ i)))
       (else
        (chcmp cmp (string-ref a i) (string-ref b i)))))))


Back to Index