Created
March 25, 2021 10:56
-
-
Save gabyfle/48a4224178c69beee0ef8ee6ab44621b 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
type 'a cell_lc = { tete : 'a ; queue : 'a lc } | |
and 'a lc = ListecVide | Listec of 'a cell_lc | |
let tete = function | |
| ListecVide -> failwith "Liste vide" | |
| Listec(cell) -> cell.tete | |
let queue = function | |
| ListecVide -> ListecVide | |
| Listec(cell) -> cell.queue | |
let enliste l x = match l with | |
| ListecVide -> { tete = x; queue = ListecVide } | |
| Listec(cell) -> { tete = x; queue = cell.queue } | |
let longueur l = | |
let rec len l n = match l with | |
| ListecVide -> n | |
| Listec(cell) -> len cell.queue (n + 1) | |
in | |
len l 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment