# [Melbourne-pm] Dancing around the event horizon

Kahlil Hodgson kahlil.hodgson at dealmax.com.au
Thu Jun 4 17:23:03 PDT 2015

On 4 June 2015 at 17:30, Sam Watkins <sam at nipl.net> wrote:

> For more readable LISP, I figure we need implicit parens around lines,
> and encompassing any indented block argument:
>
>     define
>         largest-two-square-sum x y z
>         if (= x (larger x y))
>             sum-of-squares x (larger y z)
>             sum-of-squares y (larger x z)
>
> Is more readable to me than:
>
>     (define
>         (largest-two-square-sum x y z)
>             (if (= x (larger x y))
>                 (sum-of-squares x (larger y z))
>                 (sum-of-squares y (larger x z))
>             )
>     )
>

​They look about the same to me, Sam. Perhaps throw a few list
comprehensions in there for fairness ;-)

You should really be laying out your list like so:

​(define (largest-two-square-sum x y z) (if (= x (larger x y))
(sum-of-squares x (larger y z)) (sum-of-squares y (larger x z)) ))
(define (larger x y) (if (> x y) x y))
(define (sum-of-squares x y) (+ (square x) (square y)))
(define (square x) (* x x) )

Jokes aside, the above looks like a bunch of equations from high school
algebra.  You can model the execution of the code with a process of
recursively evaluating the inner most scopes and substituting the results.
You get a sense that the code executes by continually collapsing in on
itself, becoming progressively more simple. Its kinda Zen. That model works
really well with the Virtual Machine that I'm continually running in my
head while I cut code. I find it quite meditative and satisfying.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/melbourne-pm/attachments/20150605/62876a9d/attachment.html>