0

I found excellent documentation on the problem but, I admit, I totally fail in getting a grasp on how the solutions presented in the post worked.

Given a list of integers, I would like to perform operations on adjacent elements if they match a certain criteria. For example, how can I sum the adjacent elements that are equals, so that for

let x = [1;1;2;2;2;2;3;3;4;3;3;3]
f x

I got

[2; 8; 6; 4; 9]

?

Community
  • 1
  • 1
Worice
  • 3,847
  • 3
  • 28
  • 49
  • 1
    So what exactly is your problem? I understand that you feel "lost", but until you figure out why exactly that is, which part are not clear and why, nobody can help you. Sure, we can write an explanation for you, but hasn't Tomas already done that? – Fyodor Soikin Nov 08 '16 at 17:37
  • 1
    Essentially the same question as this one: http://stackoverflow.com/q/35050960/126014 Once you have a list of lists, you can sum each sublist. Voting to close as a duplicate. – Mark Seemann Nov 08 '16 at 17:41
  • @MarkSeemann thank you for the question you posted, it actually answer my question. Should I delete this one, since it is a duplicate? – Worice Nov 08 '16 at 17:44
  • @Worice You could, but you don't have to :) – Mark Seemann Nov 08 '16 at 17:46
  • Ok, thanks for your help! – Worice Nov 09 '16 at 12:36

0 Answers0