[Haskell-beginners] take until duplicate

Francesco Ariis fa-ml at ariis.it
Sun Sep 24 19:34:10 UTC 2017


On Sun, Sep 24, 2017 at 08:31:46PM +0100, mike h wrote:
> duh! I tried
> 
> scanr  (\x acc -> x : takeWhile (/= x) acc) [] [1,2,3,4,5,3] 
> 
> which gives 
> [[1,2,3,4,5],[2,3,4,5],[3,4,5],[4,5,3],[5,3],[3],[]]
> 
> which kind of makes sense.
> 
> M

Well done, I find that :step and :show bindings are useful too
in these cases.


More information about the Beginners mailing list