Re: [Factor-talk] Accumulation of subsequences

2016-12-16 Thread Alexander Ilin
Hello, Björn! Thank you, that's exactly what I was looking for! 16.12.2016, 16:01, "Björn Lindqvist" : > I think you can use group-by from sequences.extras. It works similar > to map-runs: > > { 1 5 "hello" 2 "world" 3 6 9 "!" } [ integer? ] group-by [ swap [ sum > ] [ first ] if ] { } assoc>ma

Re: [Factor-talk] Accumulation of subsequences

2016-12-16 Thread Björn Lindqvist
I think you can use group-by from sequences.extras. It works similar to map-runs: { 1 5 "hello" 2 "world" 3 6 9 "!" } [ integer? ] group-by [ swap [ sum ] [ first ] if ] { } assoc>map . { 6 "hello" 2 "world" 18 "!" } 2016-12-16 11:16 GMT+01:00 Alexander Ilin : > Hello! > > I was solving this i

[Factor-talk] Accumulation of subsequences

2016-12-16 Thread Alexander Ilin
Hello! I was solving this issue, and it got me wondering if there is a better solution somewhere in the library. Could you check this out? I want to find consecutive runs of numbers and replace them with a sum, while preserving all other objects in the sequence (currently only strings are i