I was able to build something incredibly convoluted that accomplishes what you want, but I&#39;m sure there&#39;s a better way to do it.<br><br>unscanl1 :: (a -&gt; a -&gt; a) -&gt; [a] -&gt; [a]<br>unscanl1 f xs = (head xs) : (map (\(a:b:_) -&gt; f a b) $ convert xs)<br>
    where<br>        convert = takeWhile (\xs -&gt; length xs == 2) . map (take 2) . tails<br><br>I&#39;m also not sure if this works in the general case, but it worked with the example you gave and a couple other quick test cases I thought up. As with any case where you use head, bad stuff will happen if feed an empty list, so either add a case that matches on [] or make sure not to feed it an empty list.<br>
<br clear="all">-R. Kyle Murphy<br>--<br>Curiosity was framed, Ignorance killed the cat.<br>
<br><br><div class="gmail_quote">On Wed, Jan 11, 2012 at 23:44, Jeffrey Thornton <span dir="ltr">&lt;<a href="mailto:jeffreyjthornton@gmail.com">jeffreyjthornton@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello-<br><br>Is there standard function in Haskell that effectively does an inverse scan? For example,<br><br>    scanl1 (\ x y -&gt; x+y) [1,2,3,4] == [1,3,6,10].<br><br>So is there a very simple built-in way to do this hypothetical example?:<br>


<br>    unscanl1 (\ x y -&gt; y-x) [1,3,6,10] == [1,2,3,4]<br><br>Thanks,<br><font color="#888888"><font color="#888888">Jeffrey</font>
</font><br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br>