Post History
Haskell + hgl, 10 bytes mpn$ce~<gj Attempt This Online! Explanation mpn map across all non-empty prefixes of the input ... ce count the number of elements in each prefix equal to ... g...
Answer
#1: Initial revision
# [Haskell](https://www.haskell.org) + [hgl](https://gitlab.com/wheatwizard/haskell-golfing-library), 10 bytes ```haskell mpn$ce~<gj ```` [Attempt This Online!](https://ato.pxeger.com/run?1=m708I7E4OzUnZ8FNxczcgvyiEoXC0sSczLTM1BSFgKLUnNKUVC6oRMDS0pI0XYs1aba5BXkqyal1NulZEKGbrrmJmXkKtgop-VwKBUUKKgppCtGGOoY6RmBoCIbGOsaxCFljHXMdUx0THUugvDEQm-mYxUIMW7AAQgMA) ## Explanation - `mpn` map across all non-empty prefixes of the input ... - `ce` count the number of elements in each prefix equal to ... - `gj` the last element of that prefix. ## Reflection I'm happy with this. It doesn't take any extra steps, and the glue is cheap.