Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun split (separator splittee)
- (let ((next-index (position separator splittee)))
- (if next-index
- (cons (subseq splittee 0 next-index) (split separator (subseq splittee (1+ next-index))))
- (list splittee))))
- (defun replace-all (replacand replacee replacor)
- (let ((next-index (position replacand replacee)))
- (if next-index
- (concatenate 'string (subseq replacee 0 next-index) replacor (replace-all replacand (subseq replacee (1+ next-index)) replacor))
- replacee)))
- (defun where-found (sought-letter the-string to-do-onroute to-do-on-leaf)
- (let ((next-index (position sought-letter the-string)))
- (if next-index
- (apply to-do-onroute
- (list (subseq the-string 0 next-index)
- (subseq the-string (1+ next-index))))
- (apply to-do-on-leaf (list the-string)))))
- (defun split (separator splittee)
- (where-found separator splittee
- (lambda (pre-string post-string) (cons pre-string (split separator post-string)))
- (lambda (leaf-string) (list leaf-string))))
- (defun replace-all (to-be-replaced-string the-patient-string the-replacement-string)
- (where-found to-be-replaced-string the-patient-string
- (lambda (pre-string post-string)
- (format t "pre: ~a post: ~a the-replacement-string: ~a ~%" pre-string post-string the-replacement-string)
- (concatenate 'string pre-string the-replacement-string (replace-all to-be-replaced-string post-string the-replacement-string)))
- (lambda (leaf-string) leaf-string)))
- (format t "the cat is here: ~a ~%" (replace-all #Space "the cat is here" ""))
- (format t "the cat is here: ~a ~%" (split #Space "the cat is here"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement