[CM] mark-explode modifications

rm@fabula.de rm@fabula.de
Thu, 24 Jun 2004 13:57:47 +0200

On Wed, Jun 23, 2004 at 12:19:35PM -0700, cristopher pierson ewing wrote:
> So here's my stab at the facility of naming exploded sounds after the
> original sound they were created from:
> ;;;------find-char
> (define (find-char string char)
> 	(do ((position 0)
> 		 (i 0 (+ i 1)))
> 		((= i (string-length string)) position)
> 	  (if (char=? char (string-ref string i))
> 	  	(set! position i))))

You might want to use 'string-index'

 guile> (string-index "A long and uggly string" #\i)

You can find such gems with:

 (apropos "string")


For string handling i suggest using the SRFI module for strings:

 guile> (use-modules (srfi srfi-13))
 guile> (define (trim-name name)
 ...      (string-drop-right name (- (string-length name) (string-index name #\.))))
 guile> (trim-name "a-sound.afi")

HTH Ralf Mattes