- February 8th, 2018: We have maybe :: b -> (a -> b) -> Maybe a -> b. But we don't have list? Or do we? Define list:
list :: b -> ([a] -> b) -> [a] -> b
list nullanswer flist lst = undefined - BONUS: Both Maybe a and [a] are binary types, ... so is MonadPlus:
Maybe a = Nothing | Just a
List a = Cons a (List a) | Nil
MonadPlus m => mzero | m a `mplus` m a
Is there some generalization that maybe and list are functions of? What is that generalization? - February 6th, 2018:
You have f :: a -> [b] -> [c]
But instead of just one a you have [a]
Define g :: [a] -> [b] -> [c]
in terms of f - Daniel @leptonyu g as bs = foldl (\xs a -> f a bs ++ xs) [] as
- ptdr_bot @m0rth0n g as bs = flip f bs =<< as
- Victoria C @ToriconPrime g as bs = concat $ fmap ($ bs) (fmap f as)
- matt @themattchan g = flip $ concatMap . flip f
- Nicoλas @BeRewt g = flip (flip (>>=) . flip f) Or: g as bs = as >>= flip f bs
- Sangeet Kar @sangeet_kar g = foldMap f
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.
Friday, April 13, 2018
February 2018 1 Liner 1HaskellADay Problems and Solutions
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment