[ create a new paste ] login | about

Link: http://codepad.org/DUIJHxBA    [ raw code | output | fork ]

Scheme, pasted on Mar 8:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
(define (s357)
  (define (merge x y)
    (let ((xv (car x)) (yv (car y)))
      (cond ((< xv yv) (cons xv (lambda () (merge ((cdr x)) y))))
            ((> xv yv) (cons yv (lambda () (merge x ((cdr y))))))
            (else (cons xv (lambda () (merge ((cdr x)) y)))))))
  (define (smult s m) (cons (* (car s) m) (lambda () (smult ((cdr s)) m))))
  (define (s3 n) (cons n (lambda () (s3 (* n 3)))))
  (define (s35) (cons 1 (lambda () (merge (s3 3) (smult (s35) 5)))))
  (let ((s35r (cdr (s35)))) (cons 1 (lambda () (merge (s35r) (smult (s357) 7))))))

(define limit 100000000000000000000000000000000000)
(define (countemto lmt)(do ((nxt (s357) ((cdr nxt))) (cnt 0 (+ cnt 1))) ((> (car nxt) lmt) cnt)))
(display (time (countemto limit))) (newline)


Output:
1
2
cpu time: 890 real time: 965 gc time: 501
27608


Create a new paste based on this one


Comments: