9d7ea7bf528b

`reduce` has a `:from-end` arg
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 15 Feb 2017 10:24:14 +0000
parents 1ae69146e0e2
children cdd3f0c78257
branches/tags (none)
files src/euler.lisp

Changes

--- a/src/euler.lisp	Mon Feb 13 18:58:19 2017 +0000
+++ b/src/euler.lisp	Wed Feb 15 10:24:14 2017 +0000
@@ -507,11 +507,12 @@
                     (91 71 52 38 17 14 91 43 58 50 27 29 48)
                     (63 66 04 68 89 53 67 30 73 16 69 87 40 31)
                     (04 62 98 27 23 09 70 98 73 93 38 53 60 04 23))))
-    (car (reduce (lambda (last next)
+    (car (reduce (lambda (prev last)
                    (mapcar #'+
-                           (mapcar #'max last (rest last))
-                           next))
-                 (reverse triangle)))))
+                           prev
+                           (mapcar #'max last (rest last))))
+                 triangle
+                 :from-end t))))
 
 
 ;;;; Tests --------------------------------------------------------------------