Created
November 25, 2015 12:50
-
-
Save lpvm/40395a23a9c808d75cc5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let insert db contact = | |
if db.number_of_contacts >= Array.length db.contacts then | |
(false, db, nobody) | |
else | |
let (status, db, _) = search db contact in | |
if status then (false, db, contact) else | |
let cells i = | |
if i = db.number_of_contacts then contact else db.contacts.(i) | |
in | |
let db' = { | |
number_of_contacts = db.number_of_contacts + 1; | |
contacts = Array.init (Array.length db.contacts) cells | |
} | |
in | |
(true, db', contact);; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment