Re: [racket-dev] using the Y combinator to...

2010-08-04 Thread The Configurator
I'll hijack the thread since I've been meaning to ask about the Y
combinator.
From SICP I've seen that the Y combinator is the function
(define (y f)
  ((lambda (x) (f (x x)))
   (lambda (x) (f (x x)

This makes mathematical sense, since
(y f)
= ((lambda (x) (f (x x))) (lambda (x) (f (x x
= (f ((lambda (x) (f (x x))) (lambda (x) (f (x x)
= (f (y f))

But when actually applying it:
// g improves a function to get a ceiling function. The fixed point would be
similar to (lambda (x) (inexact-exact (ceiling x)))
(define (g f)
  (lambda (x)
(if (= x 0)
0
(+ 1 (f (- x 1))

 ((g (g (g (g (g #f) 3.3)
4

Now let's step through
((y g) 3.3)
= (((lambda (x) (g (x x))) (lambda (x) (g (x x 3.3)
= ((g ((lambda (x) (g (x x))) (lambda (x) (g (x x) 3.3)
now, to get the (g ...) result we need to apply g to it's operand. For that,
we need to evaluate it:
= ((g (g ((lambda (x) (g (x x))) (lambda (x) (g (x x)) 3.3)
= ((g (g (g ((lambda (x) (g (x x))) (lambda (x) (g (x x 3.3)
= ((g (g (g (g ((lambda (x) (g (x x))) (lambda (x) (g (x x) 3.3)

And I just ran out of memory.

What am I missing here?
It seems obvious to me that if we add a delay/force or somesuch thing it
solves the problem. But that's not the y-combinator I was shown.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev

[racket-dev] Documentation bug - 12.6.3: Reading numbrs

2010-07-27 Thread The Configurator
At the end of part 12.6.3 of the docs in
http://docs.racket-lang.org/reference/reader.html, it gives some examples

Examples:

 -1

 reads equal to

-1

 1/2

 reads equal to

(/ 1 2)

 1.0

 reads equal to

(inexact-exact 1)

 1+2i

 reads equal to

(make-complex 1 2)

 1/2+3/4i

 reads equal to

(make-complex (/ 1 2) (/ 3 4))

 1.0+3.0e7i

 reads equal to

(inexact-exact (make-complex 1 3000))

 2e5

 reads equal to

(inexact-exact 20)

 #i5

 reads equal to

(inexact-exact 5)

 #e2e5

 reads equal to

20

 #x2e5

 reads equal to

741

 #b101

 reads equal to

5

Shouldn't all the usages of inexact-exact here actually be exact-inexact ?

(I think this is the right place to ask this sort of question - if I'm
wrong, please steer me in the right direction ;)
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev