Tuesday, March 23, 2021

March 2021 1HaskellADay 1Liners

  • 2021-03-23:

    You have [a] and (a -> IO b).

    You want IO [(a, b)]

    That is, you want to pair your inputs to their outputs for further processing in the IO-domain.

    • Chris Martin @chris__martin:

      \as f -> traverse @ [] @ IO (\a -> f a >>= \b ->

      return (a, b)) as

    • cλementd Children crossing @clementd:

      traverse (sequenceA . id &&& f)

      (actually, tranverse (sequence . (id &&& f)))

      Or p traverse (traverse f . dup)

  • 2021-03-23: You have

    [([a], [b])]

    You want ([a], [b])

    so: [([1,2], ["hi"]), ([3,4], ["bye"])]

    becomes ([1,2,3,4],["hi","bye"])

    • karakfa @karakfa:

      conc xs = (concatMap fst xs, concatMap snd xs)

1 comment:

justin vijay said...

PYTHON Report is a data-centric blog run by a specialty executive search firm called AUTOMATIONMINDS SOLUTION Partners. Whether you are
an intermediate level data scientist or a pro, Data Science Report has got resources for all — it delivers resources from all variety
of formats to help the reader in understanding data science properly.

PYTHON Training in OMR Chennai