Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [<EntryPoint>]
- let main argv =
- let numbers = [ 1; 7; 7; 9; 9; 3 ]
- let series = [ (0, 1); (1, 2); (3, 2); (5, 1) ]
- let calculateSeries data =
- let rec traverseData data origin start count = seq {
- match data with
- | [] -> yield (start, count)
- | h::t ->
- if origin = h then
- yield! traverseData t origin start (count + 1)
- else
- yield (start, count)
- yield! traverseData t h (start + count) 1
- }
- match data with
- | [] -> []
- | h::t -> traverseData data h 0 0 |> List.ofSeq
- let printIntervalInfo (start, count) = printfn "%d %d" start count
- printfn "etalon series"
- series |> List.iter printIntervalInfo
- printfn "computed series"
- numbers |> calculateSeries |> List.iter printIntervalInfo
- 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement