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.
lamda operator combined with ternary expression
It checks, if both values are above 0, if so, it calculates results, if any of the numbers are below 0, result is 0.
In logical sense of this task, if 0 classmates ask him to do any amount of work ( none of them asks), there is no work to be done, if 1+ calssmates ask him to do 0 or less work, there is still no work to be done.
is this correct given that he used && and it was spcified "or" in the task.
I changed the clojure test case for negative numbers.
Indeed, the tests do not take into account negative numbers, and I did not notice.
When I try this for negative numbers, e.g. -5. I get (0) as
(let [n -5]
(range (+ 1 n)))
;=> ()
Elements on the left side of this operator => are arguments to the class, elements on the right side is the expreison of the class. ? and : are operators of boolean (if-else) expression, simply if "(n > 0 && m > 0)" is true it uses the left side of : operator if false right side. You can read more about other operators here: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/opsummary.html
I've never seen a method that looks like this. Can some explain how this works?