I'm starting my adventure with Haskell language and I need a little help. How should I define swap function which is declared:
swap :: (Int, Char) -> (Char, Int)
Probably it's very easy, but I have problem with that.
You can also be more general with:
swap :: (a, b) -> (b, a)
swap (x, y) = (y, x)
This works for all types, not just for Int and Char.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With