Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Exam2011
- type name = string
- type phone = int
- type level = int
- type description = phone * level
- type register = (phone * description) list
- let reg = [("Joe",(10101010,4));
- ("Sal",(11111111,2));
- ("Sam",(12121212,7));
- ("Jane",(13131313,1))]
- let rec getPhone n r =
- match r with
- | [] -> failwith "Register"
- | (n', (p,_))::xs -> if n = n' then p else getPhone n xs
- let delete = function
- | (n,r) -> List.foldBack (fun acc e ->
- match e with
- | (n', _) -> if n=n' then acc else e :: acc) r []
- let getCandidates le r =
- List.fold
- (fun acc r' ->
- match r' with
- | (n,(p,le')) when abs(le-le') < 3 -> (n,p)::acc
- | _ -> acc) [] r
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement