[plt-scheme] Intersperse

From: Jens Axel Soegaard (jensaxel at soegaard.net)
Date: Tue Feb 12 15:33:07 EST 2008

Is this function in one of the usual list libraries?

   (define (intersperse seperator xs)
     (cond
       [(null? xs) '()]
       [(null? (cdr xs)) xs]
       [else (cons (car xs)
                   (cons seperator
                         (intersperse seperator (cdr xs))))]))

   > (intersperse '- '(a b c d))
   (a - b - c - d)


-- 
Jens Axel Søgaard


Posted on the users mailing list.