Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • $\begingroup$ Ok, since you posted this, I am liberated from doing that (I gave it in comments to the question), and can happily upvote : +1. $\endgroup$ Commented Dec 18, 2012 at 21:03
  • $\begingroup$ +1, a variation: FoldList[Flatten@{##} &, {First@list}, Rest@list]? or FoldList[Sequence @@@ {##} &, {First@list}, Rest@list]? $\endgroup$ Commented Dec 18, 2012 at 21:06
  • $\begingroup$ @kguler I'd migrate list outside of FoldList, but I hate writing more than I have too. $\endgroup$ Commented Dec 18, 2012 at 21:15
  • $\begingroup$ @LeonidShifrin teach me to look at the comments before I post something ... Speed wise, though, is Join or Append faster. What about kguler's alternatives? $\endgroup$ Commented Dec 18, 2012 at 21:16
  • $\begingroup$ I think @kguler's use of ReplaceList is very elegant. For generic lists, should be quite fast. For packed arrays, Join and Append should be faster, since ReplaceList can not make use of those and will likely unpack. $\endgroup$ Commented Dec 18, 2012 at 21:20