Nukodi
Nukodi

Reputation: 357

F# - how to turn a list into a list of list?

I was wondering how to make a list such as

[1;2;3;4]

and turn it into

[[1];[2];[3];[4]]

I was thinking of using List.init but that didn't work

Upvotes: 3

Views: 136

Answers (1)

Rob Lyndon
Rob Lyndon

Reputation: 12691

[1;2;3;4] |> List.map (fun i -> [i])

Upvotes: 11

Related Questions