Name: Anonymous 2009-07-27 14:50
I wrote some actual programmes when you were down. Please don't leave me again.
(define (circlejerk format-list sentence)
(define fl (list->mlist format-list))
(set-mcdr! (mlast-pair fl) fl) ;make list circular XD
(let loop ((f fl) (l (split sentence)))
(if (null? l)
""
(string-append ((mcar f) (car l))
" "
(loop (mcdr f) (cdr l))))))
>(circlejerk (list b i o u) "This is one shitty thread if you know what I mean ;)")(define (list-split l pos)
(if (< pos 0)
(error "pos not a non-negative integer")
(let ((head '()))
(let loop ((tail l) (index pos))
(cond ((= index 0) (list (reverse head)
tail))
((null? tail) (error "List not long enough"))
(else
(set! head (cons (car tail) head))
(loop (cdr tail) (- index 1))))))))