Skip to main content
12 events
when toggle format what by license comment
Apr 11, 2016 at 13:55 vote accept Minh N
Apr 11, 2016 at 13:32 history closed Kuba
xzczd
xyz
Martin Ender
MarcoB
Duplicate of Any built-in function to generate successive sublists from a list?
Apr 11, 2016 at 12:38 answer added kirma timeline score: 3
Apr 11, 2016 at 11:56 comment added Minh N @kirma Yup It's very convenient. I'd say I'll stick to this one.
Apr 11, 2016 at 11:51 comment added Minh N @Kuba: I think it is safe to say that.
Apr 11, 2016 at 11:49 comment added Minh N @MartinBüttner I would say it is still acceptable, at least for me. :-)
Apr 11, 2016 at 11:34 comment added kirma In the lines of @TomD, you could define a helper function for this: ClearAll[MapAccumulate]; MapAccumulate[f_, list_List] := f@Take[list, #] & /@ Range@Length@list; ... MapAccumulate[f, mylist]
Apr 11, 2016 at 11:09 review Close votes
Apr 11, 2016 at 13:32
Apr 11, 2016 at 11:05 answer added wolfies timeline score: 2
Apr 11, 2016 at 10:54 comment added user1066 mylist = {x1, x2, x3, xN}. f@Take[mylist, #] & /@ Range[4] or Mean@Take[mylist, #] & /@ Range[4], maybe
Apr 11, 2016 at 10:23 comment added Martin Ender Would using Table be an acceptable solution or would that count as a simple loop? While Mathematica has Accumulate which performs the operation you look for for Plus, I don't think there's a way to do a generalised accumulation with an arbitrary function like Mean. Neither is there a built-in to get all the prefixes of a list, so I guess using Table or Array might be the best you can get. (E.g. Table[Mean@myList[[1 ;; i]], {i, Length@myList}])
Apr 11, 2016 at 10:16 history asked Minh N CC BY-SA 3.0