Fun exercise: Write a Haskell function `update :: Tree a → [a] → Maybe (Tree a)`, that updates the leaves of a Tree by those given in a list (if there are not enough, return Nothing). My attempt after CW

pop :: Compose (State [a]) Maybe a pop = Compose $ do xs <- get modify' (drop 1) pure (listToMaybe xs)

update = evalState . getCompose . go where go (Node _ []) = pure <$> pop go (Node x ts) = Node x <$> traverse go ts

A Mastodon instance for maths people. The kind of people who make \(\pi z^2 \times a\) jokes.
Use \( and \) for inline LaTeX, and \[ and \] for display mode.