David, with blur
Real unintelligence |
Amateur functional programming, AI, and machine learning. |
After a big storm in Toronto last week, some photographers went out
and grabbed amazing shots. I love post-storm skies (and Toronto!).
for some reason this took me a lot longer than it should have. in part because i lost my mental grip on how the linked lists are structured in memory. for example, with x shown below, (car x) is (1 2) but (cdr x) is ((3 4)). i find when writing procedures like this in scheme it's easier to grab a pen and paper, because the density of the language makes it hard for me to visualize it on screen (a common criticism of lisps).
;exercise 2.27 - deep reverse ;loop invariant: put head onto the list and process what's next (define (deep-reverse l) (define (deep-reverse-iter l accum) (cond ((null? (cdr l)) (if (list? (car l)) (cons (deep-reverse-iter (car l) ()) accum) (cons (car l) accum))) (else (if (list? (car l)) (deep-reverse-iter (cdr l) (cons (deep-reverse-iter (car l) ()) accum)) (deep-reverse-iter (cdr l) (cons (car l) accum)))))) (deep-reverse-iter l ())) (define x (list (list 1 2) (list 3 4))) ;Value 30: ((1 2) (3 4)) (reverse x) ;Value 31: ((3 4) (1 2)) (deep-reverse x) ;Value 32: ((4 3) (2 1))
(define (deep-reverse l) (define (deep-reverse-iter l accum) (let ((left-action (if (list? (car l)) (lambda (l) (deep-reverse-iter (car l) ())) (lambda (l) (car l))))) (cond ((null? (cdr l)) (cons (left-action l) accum)) (else (deep-reverse-iter (cdr l) (cons (left-action l) accum)))))) (deep-reverse-iter l ()))
There are far too many smart, educated, talented people operating at quarter speed, unsure of their place in the world, contributing far too little to the productive engine of modern civilization. There are far too many people who look like they have their act together but have yet to make an impact. You know who you are. It comes down to a simple gut check: You either love what you do or you don't. Period.
(from http://www.fastcompany.com/magazine/66/mylife.html, via HN)
this is precisely how i see things. if you find something you love, you will be good at it and you will enjoy doing it (and unsurprisingly, these are highly correlated results). right now i'm searching for something that makes me feel this way. i've already tried a number of directions at a young age, and in each one people have told me that i'm good at what i do. yet, in all cases, i haven't lived up to the most important standards: my own.