Thursday, January 21, 2021

January 2021 1HaskellADay 1Liners

  • 2021-01-28: Opposite problem:
    You have: [(a, Set b)]
    you want: [(a, b)]
    e.g.:  [("hi", fromList [1,2,3]), ("bye", fromList [4,6,7]) ->
    [("hi",1),("hi",2),("hi",3),("bye",4),("bye",6),("bye",7)]
    Interestingly, Set is not a Monad. wut. How do you get around that problem?
    • D Oisín Kidney @oisdk (>>= traverse toList)
    • mine: concatMap (sequence . second Set.toList)
  • 2021-01-28: 
    We have [(Set a, b)]
    we want [(a, b)] 
    where each element of Set a is paired with b, e.g.:
    [(fromList [1,2,3], 'a'), (fromList [4,5,6], 'b')]
    becomes
    [(1,'a'),(2,'a'),(3,'a'),(4,'b'),(5,'b'),(6,'b')]
    • Steve "wash your hands" Trout @strout:
      concatMap (uncurry (liftA2 (,)) . bimap toList pure)
    • insatiable mask wearer @tim_1729
      [(a,b) | (s,b) <- xs, a <- (toList s)]
  • Today, 2021/01/21, is:
    1. Can be written with only 3 digits, What other dates can be so written? Also:
    2. a day where the month and day are NOT amalgamation the year. But which dates are amalgamations?

Wednesday, January 20, 2021

January 2021 1HaskellADay Problems and Solutions