tlauer
tlauer

Reputation: 588

Scheme interpreter - why can't this be computed?

Procedure:

(define (double fn) (lambda (x) (fn (fn x))))

Why can't the following be computed with the Scheme interpreter:

((((((double double) double) double) double) 1+) 0)

Upvotes: 1

Views: 196

Answers (1)

Óscar López
Óscar López

Reputation: 235984

Sure it can be computed, it's just that the number of computations is growing exponentially for each double that's being called ... if you wait a very, very long time you'll eventually get your answer (how long? anything between a couple of hours or a couple of centuries).

(((double double) 1+) 0)
=> 4
((((double double) double) 1+) 0)
=> 16
(((((double double) double) double) 1+) 0)
=> 65536
((((((double double) double) double) double) 1+) 0)
=> ... ; takes too long to compute!

Upvotes: 3

Related Questions