Live data from Hacker News

Structure and Interpretation of Computer Programs, Second Edition (ePub)

github.com

21–23 of 23 posts

Re: Structure and Interpretation of Computer Programs, Second Edition (ePub)

#21
post #17

If there is one book that made me think differently about programming its this one. Oh I did know common lisp, and other languages like C/C++, Python etc. But till then it was all about language features being built in for me. Which is all good and useful. Only problem is that I didn't realize that all this can be built upon some very simple fundamental concepts. So when this book started with _only_ car, cdr and lam…

even cons, car and cdr can be done with lambda, which adds to the mind bending.

    > (define (cons a b) (lambda (f) (f a b)))
    > (define (car c) (c (lambda (a b) a)))
    > (define (cdr c) (c (lambda (a b) b)))
    > (car (cdr (cons 1 (cons 2 (cons 3 '())))))
    2

Re: Structure and Interpretation of Computer Programs, Second Edition (ePub)

#22
post #12

Earlier quoted context omitted.

If you put the URL into Safari on your iPad, it should prompt you to open it in iBooks.

doesn't work for me. It only offers to open the .epub file in Stanza or GoodReader. iBooks is not shown as a possible choice.

Wow, lame. It works with PDF, I assumed it would work with ePub. I assumed wrong.

Re: Structure and Interpretation of Computer Programs, Second Edition (ePub)

#23
post #17

If there is one book that made me think differently about programming its this one. Oh I did know common lisp, and other languages like C/C++, Python etc. But till then it was all about language features being built in for me. Which is all good and useful. Only problem is that I didn't realize that all this can be built upon some very simple fundamental concepts. So when this book started with _only_ car, cdr and lam…

even cons, car and cdr can be done with lambda, which adds to the mind bending. > (define (cons a b) (lambda (f) (f a b))) > (define (car c) (c (lambda (a b) a))) > (define (cdr c) (c (lambda (a b) b))) > (car (cdr (cons 1 (cons 2 (cons 3 '()))))) 2

And of course, even lambda is unnecessary. Using two combinators, customarily called s and k suffices:

  k x y = x
  s x y z = x z (y z)
This system is called the SKI-calculus (http://en.wikipedia.org/wiki/SKI_combinator_calculus). The I in SKI stands for the identity, and can be expressed in terms of s and k.

As an example, here is the y-combinator:

  y = s s k (s (k (s s (s (s s k)))) k)
Post reply on HN