Arc Cross Reference

trim

[procedure] trim s where (o test whitec)

(def trim (s where (o test whitec))
  (let p1 (pos [no (test _)] s)
    (if p1
        (subseq s 
                (if (in where 'front 'both) p1 0)
                (when (in where 'end 'both)
                  (let i (- (len s) 1)
                    (while (and (> i p1) (test (s i)))
                      (-- i))
                    (+ i 1))))
        "")))