William James
4/1/2015 7:19:00 PM
Kalle Olavi Niemitalo wrote:
> Ken Tilton <kentilton@gmail.com> writes:
>
> > when (getf ....)
> > collect (cons (first slot-def) it) ;; "it" = obscure loop trick
>
> IT works only immediately after another loop keyword; not when
> shielded from sight by parentheses.
>
>
> * (loop for x on '(a nil c) when (car x) collect (cons x it))
>
> debugger invoked on a UNBOUND-VARIABLE in thread #<THREAD "initial thread"
> {9003299}>:
> The variable IT is unbound.
>
>
> * (loop for x on '(a nil c) when (car x) collect :it)
>
> (A C)
Scheme (Gauche and Racket):
(define (common-factor m n)
(define d (gcd m n))
(and (> d 1) d))
(filter-map common-factor
'(33 34 35 36 37)
'(84 85 86 87 88))
===>
(3 17 3)
Also works under Larceny, with this addition:
(require 'srfi-1)