
On 05/04/07, Kurt Hutchinson
Straightforward:
ssfold p f z = head . dropWhile ( not . p ) . scanl f z
I'd prefer find instead of head . dropWhile (not . p), making the result type a Maybe, as this is essentially equivalent to searching through the result of a scan for a specific value, so it should follow find's example and use Maybe for its partiality.
I want to see some real creativity here, so pull out all the stops.
You may also be interested in the Compose experiment [1]: a bit of fun seeing how many different ways compose :: [a -> a] ->(a -> a) could be defined. Most are quite silly, but the solution involving the State monad, for example, is really quite elegant. [1]: http://haskell.org/haskellwiki/Compose -- -David House, dmhouse@gmail.com