- March 30th, 2017:
divide :: (a -> Either b c) -> [a] -> ([b], [c]) This function is somewhere easy to get to, right?
via @fmapE - @fmapE: divide f = foldr (either (first . (:)) (second . (:)) . f) ([], [])
- SocialJusticeCleric @walkstherain divide f = Data.Either.partitionEithers . fmap f
- andrus @andrus divide f = foldMap $ (swap . pure . pure ||| pure . pure) . f
- matt @themattchan divide = partitionEithers ... map where ... = (.).(.)
- March 13th, 2017:
Palindromes have nothing to do with today's #haskell problem of anagrams. So what.
Define
palindrome :: String -> Bool
elegantly - SocialJusticeCleric @walkstherain all id . (zipWith (==) =<< reverse)
- SocialJusticeCleric added: TIL Data.Foldable.and
- bazzargh @bazzargh ap (==) reverse?
- March 13th, 2017:
type Bag a = Map a Int
anagram :: Ord a => [a] -> [a] -> Bool
anagram src = (== Bag.fromList src) . Bag.fromList
Redefine with <*> - Denis Stoyanov @xgrommx why not?
anagram = (==) `on` Bag.fromList
Incorporates strong typing over predicate logic programming, and, conversely, incorporates predicate logic programming into strongly typed functional languages. The style of predicate logic is from Prolog; the strongly typed functional language is Haskell.
Tuesday, April 11, 2017
March 2017 1HaskellADay 1Liners
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment