Created
March 15, 2026 08:45
-
-
Save lhitori/d1a99abf8972c66eac042e283e20e21c to your computer and use it in GitHub Desktop.
Tri Fusion en OCaml
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
| (* Implémentation du Tri Fusion en OCaml *) | |
| let rec separer : 'a list -> 'a list * 'a list = function | |
| | [] -> ([], []) | |
| | [ x ] -> ([ x ], []) | |
| | x :: y :: tl -> | |
| let xs, ys = separer tl in | |
| (x :: xs, y :: ys) | |
| and fusionner : 'a list * 'a list -> 'a list = function | |
| | [], l | l, [] -> l | |
| | x :: xs, y :: ys -> | |
| if x < y then x :: fusionner (xs, y :: ys) | |
| else y :: fusionner (x :: xs, ys) | |
| and trier : 'a list -> 'a list = function | |
| | [] -> [] | |
| | [ x ] -> [ x ] | |
| | xs -> | |
| let ys, zs = separer xs in | |
| fusionner (trier ys, trier zs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment