MCPcopy Create free account
hub / github.com/EntilZha/PyFunctional / distinct_by_t

Function distinct_by_t

functional/transformations.py:156–171  ·  view source on GitHub ↗

Transformation for Sequence.distinct_by :param func: distinct_by function :return: transformation

(func)

Source from the content-addressed store, hash-verified

154
155
156def distinct_by_t(func):
157 """
158 Transformation for Sequence.distinct_by
159 :param func: distinct_by function
160 :return: transformation
161 """
162
163 def distinct_by(sequence):
164 distinct_lookup = {}
165 for element in sequence:
166 key = func(element)
167 if key not in distinct_lookup:
168 distinct_lookup[key] = element
169 return distinct_lookup.values()
170
171 return Transformation("distinct_by({0})".format(name(func)), distinct_by, None)
172
173
174def sorted_t(key=None, reverse=False):

Callers

nothing calls this directly

Calls 1

nameFunction · 0.85

Tested by

no test coverage detected