[pure-lang-svn] SF.net SVN: pure-lang:[879] pure/trunk/lib/prelude.pure
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-09-27 04:41:08
|
Revision: 879 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=879&view=rev Author: agraef Date: 2008-09-27 04:41:02 +0000 (Sat, 27 Sep 2008) Log Message: ----------- Simplify definition of cat. Modified Paths: -------------- pure/trunk/lib/prelude.pure Modified: pure/trunk/lib/prelude.pure =================================================================== --- pure/trunk/lib/prelude.pure 2008-09-27 04:15:24 UTC (rev 878) +++ pure/trunk/lib/prelude.pure 2008-09-27 04:41:02 UTC (rev 879) @@ -452,16 +452,14 @@ /* Concatenate a list of lists. */ cat [] = []; -cat xs@(_:_) = foldr (+) [] xs +cat xs@(_:_) = foldr (tick []) [] xs with /* Unfortunately, the global list concatenation operator (+) isn't fully lazy in Pure, because it's also used for arithmetic operations. Using it here would make foldr (and hence cat) eager. Therefore we use our own concatenation operation here, which properly deals with the case that ys is an infinite stream when applied recursively. */ - []+ys = ys; - xs@(_:_)+ys = tick [] xs ys; - tick zs (x:xs) ys = tack (x:zs) ((xs+ys)&) if thunkp xs; + tick zs (x:xs) ys = tack (x:zs) (tick [] xs ys&) if thunkp xs; = tick (x:zs) xs ys; tick zs [] ys = tack zs ys; tick zs xs ys = tack zs (xs+ys); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |