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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
They are the arguments of the function, like in any other program (python
def f(xs):
). But sometimes it is possible to not write them, like here, if we can write the code in pure terms of functions combinations. It's hard to explain clearly (and I'm far from being comfortable in Haskell) but try to practice on easy katas and look at others solutions, try to reuse them... With Haskell installed on your computer you can run a very handy interpreter that allows to do tiny tests easily.can someone explain this. Very new to haskell.
I am wondering why "xs" or any form of agruement is being used before the equal sign?
so cool!
Really cool approach. It's these kinds of code that made me learn haskell at first. Doing simple things the simple way
Yeah, that was silly of me
True, but just in case ;)
You
mod 60
but youmod 10
the hard way ?!?take 60
is unnecessary. Haskell is lazy.No, siempre hay una forma mas redusida jajaj
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
):Thank you! It's so satisfying to lay things out his way :)
what is bimap?
Very nice, and well laid out!
Loading more items...