Created
November 24, 2022 17:38
-
-
Save efvincent/2dc0cd023dea2700d726fe7a1420a9cc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| Inductive partial_map : Type := | |
| | Empty | |
| | Binding (k : nat) (v : nat) (m : partial_map). | |
| (** update given in the lecture. map will continue to grow, updated | |
| pairs aren't removed - not a realistic representation is it? *) | |
| Definition update' (k v : nat) (m : partial_map) : partial_map := | |
| Binding k v m. | |
| (** alternative that replaces the updated node at the key *) | |
| Fixpoint update (k v : nat) (m : partial_map) : partial_map := | |
| match m with | |
| | Empty => Binding k v Empty | |
| | Binding k' v' m' => | |
| if k =? k' | |
| then Binding k v m' | |
| else Binding k' v' (update k v m') | |
| end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment