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.
Simple example:
bimap (+ 10) (* 13) (7, 3) = (17, 39)
So,
(bimap f g (a,b))
appliesf
toa
, andg
tob
, while maintaining the tuple structure.Another example, but with
Either
:Now, a clever trick is to apply
join
tobimap
. It happens to be the case thatjoin bimap
applies the same function to both parts of a tuple:The reason this works is due to the definition of
join
and the monad instance for functions (i.e.(->) r
):This comment is hidden because it contains spoiler information about the solution
It's all about "$". When there's enough dollars, work gets done.