Clojure "Accumulate" Tests Return Errors but My Solution Works for 4 of 5 Cases
SSShupe opened this issue · comments
My solution for the "Accumulate" exercise works on four of the five test collections locally (all but the "recursive" collection), but throws an error when I run the test suite. The solution is a straightforward loop-recur (below). The error is
ERROR in (empty-accumulation) (RT.java:667)
expected: (= [] (accumulate/accumulate square []))
actual: java.lang.UnsupportedOperationException: count not supported on this type: accumulate_test$square
Am I missing something? I'm an amateur coder so that's entirely possible.
I should add that in general I think Exercism is amazing.
(defn accumulate [collection operation]
(loop [new-c []
old-c collection]
(if (= (count old-c) 0)
new-c
(recur (conj new-c (operation (first old-c))) (rest old-c)))))
@SSShupe All you need to do is switch the order of the args:
(defn accumulate [operation collection]
. . .
I'm an idiot. Sorry for the bother, I should have seen that.
SSS
…On Thu, Oct 14, 2021 at 1:59 PM Bobby Towers ***@***.***> wrote:
@SSShupe <https://github.com/SSShupe> All you need to do is switch the
order of the args:
(defn accumulate [operation collection]. . .
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#445 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACEJGZSOO3LU4SJX26FQTKTUG5AERANCNFSM5GAP7M3A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.