Created
August 6, 2017 04:08
-
-
Save kunigami/d87fcd3f088db5fcb27f20b518ad866c 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 push elem {frontSize; front; rearSize; rear; rotation} = | |
check { | |
frontSize; | |
front; | |
rearSize = rearSize + 1; | |
rear = elem :: rear; | |
rotation; | |
} | |
;; | |
let peek {frontSize; front; rearSize; rear; rotation} = match front with | |
| [] -> raise Empty_queue | |
| firstElem :: restFront -> firstElem | |
;; | |
let pop {frontSize; front; rearSize; rear; rotation} = match front with | |
| [] -> raise Empty_queue | |
| firstElem :: restFront -> | |
let newState = invalidate rotation in | |
check { | |
frontSize = frontSize - 1; | |
front = restFront; | |
rearSize; | |
rear; | |
rotation = newState; | |
} | |
;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment