Last active
December 10, 2015 04:28
-
-
Save linstantnoodles/4381630 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
let rec sublists a = match a with | |
[] -> [[]] | |
|first::rest -> let b = sublists rest in | |
let c = List.map (fun g -> first::g) b in | |
c @ b;; | |
(* | |
val sublists : 'a list -> 'a list list = <fun> | |
# let a = [1;2;3];; | |
val a : int list = [1; 2; 3] | |
# sublists a;; | |
- : int list list = [[1; 2; 3]; [1; 2]; [1; 3]; [1]; [2; 3]; [2]; [3]; []] | |
*) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment