Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Хитрец.
Thanks, I'm glad you explained this.
Empty arrays are no longer possible.
<*>
is a better fit than>>=
forzipWith .. tail
. When fed an empty list,zipWith (*) [] (tail [])
returns[]
without evaluatingtail []
.zipWith (*) (tail []) []
crashes. That's why you want the second list to be shorter, thus<*>
.In this case,
maximum []
will crash anyway, so it doesn't matter, you need a list of at least two elements to succeed at all.This is the common mathematical definition of an empty product. Note that also
a^0
denotes kind of an empty product (you multiply zeroa
s) and we all would agree that this equals to1
. (Or maybe not agree, but still we learned this in school) See also https://en.wikipedia.org/wiki/Empty_productAnd it wants the product of an empty array to be 1. I'd have thought 0 made more sense.
This comment is hidden because it contains spoiler information about the solution
the important bit here is that "*" is nothing special in Clojure. It is just a function that happens to be built-in the standard library, but is otherwise a normal Clojure function. You can see it's source there: https://github.com/clojure/clojure/blob/clojure-1.9.0/src/clj/clojure/core.clj#L1000-L1010
Weird language
This comment is hidden because it contains spoiler information about the solution
Sorry, but not an issue ;-)
why have someone write essentially the same line of code 5x?
Why should we repeat the same function 5 times?
RUN SAMPLE TESTS doesn't work reporting
Attemp works.