Skip to content

Instantly share code, notes, and snippets.

@noss
Created January 19, 2009 14:29
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save noss/49008 to your computer and use it in GitHub Desktop.
-module(index).
-compile(export_all).
invert({Ks, Image}) ->
[{K, Image} || K <- Ks].
update_index(KIs, Index0) ->
lists:foldl(fun({K, I}, Acc) ->
dict:append(K, I, Acc)
end,
Index0, KIs).
build_index(Docs) ->
Index = dict:new(),
lists:foldl(fun (Doc, Acc) -> update_index(invert(Doc), Acc) end,
Index, Docs).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment