Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2014
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.55 KB | None | 0 0
  1. let calculateSeries = function
  2.     | [] -> []
  3.     | x :: xs ->
  4.         let length, _, lastSeriesLength, otherSeries =
  5.             List.fold (fun (i, thisSeriesValue, thisSeriesLength, otherSeries) x ->
  6.                 if x = thisSeriesValue then
  7.                     i+1, thisSeriesValue, thisSeriesLength+1, otherSeries
  8.                 else
  9.                     i+1, x, 1, (i - thisSeriesLength + 1, thisSeriesLength) :: otherSeries
  10.             ) (0, x, 1, []) xs
  11.         (length - lastSeriesLength + 1, lastSeriesLength) :: otherSeries
  12.         |> List.rev
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement