All n combinations from a list, in 6 lines of scheme:
(define (combinations n lis output)
(cond ((= n 0)
(output '()))
((not (null? lis))
(begin (combinations (- n 1) (cdr lis) (lambda (x) (output (cons (car lis) x))))
(combinations n (cdr lis) output)))))
(combinations 3 '(a b c d e f g) (lambda (x) (display x) (newline)))
:w !scm
#<unspecified>
(a b c)
(a b d)
(a b e)
(a b f)
(a b g)
(a c d)
(a c e)
(a c f)
(a c g)
(a d e)
(a d f)
(a d g)
(a e f)
(a e g)
(a f g)
(b c d)
(b c e)
(b c f)
(b c g)
(b d e)
(b d f)
(b d g)
(b e f)
(b e g)
(b f g)
(c d e)
(c d f)
(c d g)
(c e f)
(c e g)
(c f g)
(d e f)
(d e g)
(d f g)
(e f g)
#<unspecified>
by the way, did you know that you can pipe the content of a file being editted in vim to a command using: