Lisp

I deciced to give Lisp a try and currently I’m struggling with a lot of parentheses and a lot of lambdas. Anyway, for the first day (or night) I’m really proud of this beauty: 🙂

;; Problem 3-9 (without tolerance)
(defun rightp (a b c)
(let ((longest-side-square (expt (car (sort (list a b c) '>)) 2))
(shorter-side-square-sum (apply '+ (mapcar (lambda (x) (expt x 2))
(cdr (sort (list a b c) '>))))))
(= longest-side-square shorter-side-square-sum)))

Thanks to Manuel of the BKNR project for their htmlize.lisp code!

Leave a Reply