Welcome to the CHICKEN Scheme pasting service

no title added by anonymous on Sat Jun 11 06:03:23 2011

(define (check1 a b)
  (if (null? a) #t
    (if (list? (member (car a) b)) (check1 (cdr a) b) #f)))

(define (split x)
  (let rec ((lst '()) (quot x))
    (if (zero? quot) lst
      (rec (cons (remainder quot 10) lst) (quotient quot 10)))))

(define (check2 lst)
  (if (null? lst) #t
    (if (null? (cdr lst)) #t #f)))

(define (check x)
  (let rec ((lst (list (split x) (split (* x 2)) (split (* x 3)) (split (* x 4)) (split (* x 5)) (split (* x 6)))))
    (if (check2 lst) #t
      (if (check1 (car lst) (cadr lst)) (rec (cdr lst)) #f))))

(define euler52 
  (let rec ((x 1))
    (if (check x) x (rec (+ x 1)))))

(display euler52)(newline

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which procedure can be used to check whether its argument is a procedure?
Visually impaired? Let me spell it for you (wav file) download WAV