Skip to content

Instantly share code, notes, and snippets.

@gabyfle
Created March 25, 2021 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabyfle/48a4224178c69beee0ef8ee6ab44621b to your computer and use it in GitHub Desktop.
Save gabyfle/48a4224178c69beee0ef8ee6ab44621b to your computer and use it in GitHub Desktop.
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