About archiving my SICP related stuff on GitHub

Well, I have done some exercises offered by the books Simply Scheme and the SICP for my own personal development and joy.

One interesting example is the representation of pairs as procedures. Instead of using a data structure we can use ordinary procedures to achieve the same, with identical semantics.

;;; Procedural representation of pairs
(define (cons x y)
  (define (dispatch m)
    (cond ((= m 0) x)
	  ((= m 1) y)
	  (else (error "Only 0 or 1 is allowed as argument -- CONS" m))))
  dispatch)

(define (car z)
  (z 0))

(define (cdr z)
  (z 1))

Another example

;;; Procedural representation of pairs
(define (cons x y)
  (lambda (m) (m x y)))

(define (car z)
  (z (lambda (p q) p)))

(define (cdr z)
  (z (lambda (p q) q)))

Or another example introducing mutation on top of that

(define (cons x y)
  (define (set-x! v) (set! x v))
  (define (set-y! v) (set! y v))
  (define (dispatch m)
    (cond ((eq? m 'car) x)
	  ((eq? m 'cdr) y)
	  ((eq? m 'set-car!) set-x!)
	  ((eq? m 'set-cdr!) set-y!)
	  (else (error "Undefined operation -- CONS" m))))
  dispatch)

(define (car z) (z 'car))

(define (cdr z) (z 'cdr))

(define (set-car! z new-value)
  ((z 'set-car!) new-value)
  z)

(define (set-cdr! z new-value)
  ((z 'set-cdr!) new-value)
  z)

To see more, please take a look at: SICP and Simply Scheme.

Related stuff:

About archiving my SICP related stuff on GitHub

About some of the Big Ideas in CS, based on the SICP

I created a new repo on GitHub, where I plan to collect some cool ideas in CS based on the influential work of Harold Abelson, Gerald J. Sussman with Julie Sussman, the SICP.

My goal is to write about these Big Ideas and also to show them in various programming languages like Scheme, Ruby, JavaScript, etc.

If you understand these concepts, then using them in different programming languages is easy, since you only need to learn the particular notation. (Of course only if the given language supports the particular feature necessary…)

It’s quite amazing, that there are only a few very powerful features required anyways. (Read the SICP to learn about them!)

My GitHub repo about the topic can be accessed here. Check it out!

About some of the Big Ideas in CS, based on the SICP

Thinking about Software Engineering

Why companies are looking for coding skills in a particular programming language, instead of looking for understanding of the set of abstract ideas behind the programming languages?

When someone understands the big ideas behind, then picking up one particular language’s syntax and semantics is pretty straightforward. Given that you already know the concepts, pairing the language’s syntax with a familiar concept is the remaining work you need to put into.

The other way around, if you know only one or two languages with a limited set of paradigms and concepts behind, it is much harder to pick up UNDERSTANDING of other languages…

Programming languages can come and go, and you will be in big trouble if you lack understanding…

References

Thinking about Software Engineering