Current section

Files

Jump to
datastructures lib data protocol reduce.ex
Raw

lib/data/protocol/reduce.ex

# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
# 0. You just DO WHAT THE FUCK YOU WANT TO.
alias Data.Protocol.Reduce, as: Protocol
defprotocol Data.Protocol.Reduce do
@spec reduce(t, any, (any, any -> any)) :: any
def reduce(self, acc, fun)
end
defimpl Protocol, for: List do
defdelegate reduce(list, acc, fun), to: List, as: :foldl
end
defimpl Protocol, for: Map do
defdelegate reduce(self, acc, fun), to: Map
end
defimpl Protocol, for: MapSet do
defdelegate reduce(self, acc, fun), to: MapSet
end
defimpl Protocol, for: HashSet do
defdelegate reduce(self, acc, fun), to: HashSet
end