Thursday, February 11, 2016

January 2016 Haskell One-liners

  • January 26th, 2016: define line2Bio so that
    *Main> line2Bio "Birches by Robert Frost" ~> ("Birches","Robert Frost")
    (in 1 line)
    • Gautier DI FOLCO @gautier_difolco
      import Data.Bifunctor
      line2Bio = bimap unwords (unwords . tail) . break (== "by") . words
    • matthieu bulté @matthieubulte
      line2Bio = on bimap (unwords .) id tail . break (== "by") . words
  • January 26th, 2016: define swap points-free:
    swap :: (a,b) -> (b, a)
    • matthieu bulté @matthieubulte
      swap = uncurry (flip (,))
    • Noah Luck Easterly @walkstherain
      uncurry $ flip (,)
    • Андреев Кирилл @nonaem00
      import Control.Arrow
      swap = snd &&& fst

No comments: