Advertisement
Guest User

Untitled

a guest
May 14th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.42 KB | None | 0 0
  1. let rec rapikan = function
  2. | [] -> []
  3. | [(p, k)] -> if k = 0.0 then [] else [(p, k)]
  4. | (p1, k1)::(p2, k2)::t -> if p1 = p2 then
  5.                                if k1+k2 = 0.0 then rapikan t
  6.                                else (p1, k1+k2)::rapikan t
  7.                            else
  8.                                if k1 = 0.0 then rapikan ((p2, k2)::t)
  9.                                else (p1, k1)::rapikan ((p2, k2)::t);;
  10.  
  11. let normalisasi a = rapikan (List.rev(List.sort a));;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement