Travis build: 98

This commit is contained in:
30secondsofcode
2019-09-22 12:23:27 +00:00
parent ab3c44a5d5
commit 99374f1c2e
3 changed files with 7 additions and 10 deletions

View File

@@ -513,10 +513,7 @@ Use list comprehension to map each element to the appropriate `key`.
```py
def group_by(lst, fn):
groups = {}
for key in list(map(fn,lst)):
groups[key] = [item for item in lst if fn(item) == key]
return groups
return {key : [el for el in lst if fn(el) == key] for key in map(fn,lst)}
```
<details>
@@ -524,8 +521,8 @@ def group_by(lst, fn):
```py
import math
group_by([6.1, 4.2, 6.3], math.floor); # {4: [4.2], 6: [6.1, 6.3]}
group_by(['one', 'two', 'three'], len); # {3: ['one', 'two'], 5: ['three']}
group_by([6.1, 4.2, 6.3], math.floor) # {4: [4.2], 6: [6.1, 6.3]}
group_by(['one', 'two', 'three'], len) # {3: ['one', 'two'], 5: ['three']}
```
</details>