Created
December 29, 2010 18:25
-
-
Save dgfitch/758837 to your computer and use it in GitHub Desktop.
This file contains 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 book = Map [(1, ["daniel"; "martin"; "bella"]); (2, ["daniel"; "martin"]); (3, ["bella"])];; | |
let words = book |> Map.toList |> List.map snd |> List.concat |> Set.ofList | |
let inverseBook = | |
[ for word in words do | |
let pages = | |
book | |
|> Map.toList | |
|> List.choose (fun (page, pageWords) -> if List.exists ((=) word) pageWords then Some page else None) | |
yield word, pages ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment