2 people like it.

Powerset

Powerset of set represented as a list. Does not check for repeated elements

1: 
2: 
3: 
let rec powerset = function
                   | [] -> [[]]
                   | h::t -> List.fold (fun xs t -> (h::t)::t::xs) [] (powerset t);
val powerset : _arg1:'a list -> 'a list list

Full name: Script.powerset
val h : 'a
val t : 'a list
Multiple items
module List

from Microsoft.FSharp.Collections

--------------------
type List<'T> =
  | ( [] )
  | ( :: ) of Head: 'T * Tail: 'T list
  interface IEnumerable
  interface IEnumerable<'T>
  member Head : 'T
  member IsEmpty : bool
  member Item : index:int -> 'T with get
  member Length : int
  member Tail : 'T list
  static member Cons : head:'T * tail:'T list -> 'T list
  static member Empty : 'T list

Full name: Microsoft.FSharp.Collections.List<_>
val fold : folder:('State -> 'T -> 'State) -> state:'State -> list:'T list -> 'State

Full name: Microsoft.FSharp.Collections.List.fold
val xs : 'a list list
Raw view Test code New version

More information

Link:http://fssnip.net/4b
Posted:13 years ago
Author:Andrew Le Couteur Bisson
Tags: powerset list