Hacker News new | ask | show | jobs
by htp 4865 days ago
I personally have trouble quickly parsing expressions like sin(1 + (5 + x + y) / (n + k)), but do really well with things like:

    (sin (+ 1 (/ (+ 5 x y)
                 (+ n k))))
Similarly, your Lisp could be reformatted to something like:

    (define (qualifies-for-free-shipping item-price weight shipping-factor category)
        (let* ((item-cost (* item-price TAX-RATE))
               (shipping-cost (+ (* weight shipping-factor) 2))
               (total-price (+ item-cost shipping-cost)))
         (cond ((in category FREE-SHIPPING-CATEGORIES) #t)
               ((>= item-cost 80) #t)
               ((and (>= total-price 100) (in category ELECTRONICS-CATEGORIES)) #t)
               (else #f))))
I think you’re trying to use Lisp as if it were Python, and that’s going to make things more difficult for you than they need to be.

(A lot of my college classmates ran into trouble in a class where we programmed in Scheme [since renamed to Racket] because they tried to use it like Java, the standard curriculum language. If/when they grokked Scheme, they became just as proficient in it as they were in Java, but until they did they spent a lot of time effectively complaining about how Scheme wasn’t Java.)