Reputation
1,198
Next privilege 2,000 Rep.
Edit questions and answers
Badges
7 25
Impact
~23k people reached

  • 0 posts edited
  • 0 helpful flags
  • 53 votes cast
1d
accepted Splitting a list into increasing sublists
1d
awarded  Nice Question
1d
comment Splitting a list into increasing sublists
@ciao But an elegant solution is always preferred.
1d
comment Splitting a list into increasing sublists
Performance is not particularly important. You can assume the list will have under 1000 elements.
1d
comment Splitting a list into increasing sublists
I think the Catch and inner While can be replaced by the following, which completely avoids an inner loop: While[Length@c > 0, d = Accumulate@c; n = Max@FirstPosition[d, x_ /; x > Total@Last@b, Length@d]; b = Append[b, Take[c, n]]; c = Drop[c, n]];
1d
comment Splitting a list into increasing sublists
@march Fair enough. To be honest, I was hoping I was just missing something in SplitBy, or that another primitive would do the trick, and I wouldn't have to write anything.
1d
comment Splitting a list into increasing sublists
Nice solution, thanks. That's along the lines of what I was thinking in my comment above, but done more elegantly than I would probably have written it. I was hoping for a solution that didn't involve explicit loops.
1d
comment Splitting a list into increasing sublists
Well, the only thing I've tried is a complicated solution involving keeping track of the current sum and the tail of the list and using that to find the next greater head.
1d
asked Splitting a list into increasing sublists
May
22
awarded  Good Question
May
7
asked ImageSize in Export
Mar
31
comment Matching x,y,z,2
@rasher Oh, I see. It's totally the way you'd expect it to work for functions.
Mar
31
comment Matching x,y,z,2
@rasher I meant for the list to be grown to the left; sorry, I thought that was clear. As for overlaps, it turns out in my application that they don't matter --- that is, whether they are done sequentially or simultaneously you will eventually get the same result (I am intending to use ReplaceAll once I get this working).
Mar
31
comment Matching x,y,z,2
I understand your point about functions being represented as rules. But is there a reason other than "we chose to do it that way" for filling from right to left, which is to me counterintuitive? I thought about using multiple rules, but figured there had to be a better way.
Mar
30
revised Matching x,y,z,2
added 82 characters in body
Mar
30
asked Matching x,y,z,2
Mar
25
awarded  Popular Question
Mar
20
awarded  Yearling
Mar
11
awarded  Notable Question
Mar
4
comment Determine if all the zeros in a list occur at the end
Accepting this answer because a) it was first, and b) Kuba showed extraordinary perseverance.