Update formatting
Update formatting in every_nth Update formatting in shuffle Update formatting in has_duplicates Update formatting in group_by Update formatting in sum_by Update formatting in zip Update formatting in longest_item Update formatting in bifurcate_by Update formatting in difference_by Update formatting in clamp_number Update formatting in min_by Update formatting in max_by Update formatting in union Update formatting in n_times_string Update formatting in check_prop Update formatting in chunk Update formatting in transpose Update formatting in bifurcate Update formatting in union_by Update formatting in initialize_list_with_range Update formatting in most_frequent
This commit is contained in:
@ -17,5 +17,8 @@ def bifurcate_by(lst, fn):
|
||||
```
|
||||
|
||||
```py
|
||||
bifurcate_by(['beep', 'boop', 'foo', 'bar'], lambda x: x[0] == 'b') # [ ['beep', 'boop', 'bar'], ['foo'] ]
|
||||
bifurcate_by(
|
||||
['beep', 'boop', 'foo', 'bar'],
|
||||
lambda x: x[0] == 'b'
|
||||
) # [ ['beep', 'boop', 'bar'], ['foo'] ]
|
||||
```
|
||||
|
||||
@ -14,10 +14,7 @@ def check_prop(fn, prop):
|
||||
|
||||
```py
|
||||
check_age = check_prop(lambda x: x >= 18, 'age')
|
||||
user = {
|
||||
'name': 'Mark',
|
||||
'age': 18
|
||||
}
|
||||
user = {'name': 'Mark', 'age': 18}
|
||||
|
||||
check_age(user) # True
|
||||
```
|
||||
|
||||
@ -14,7 +14,7 @@ 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]}
|
||||
from math import floor
|
||||
group_by([6.1, 4.2, 6.3], floor) # {4: [4.2], 6: [6.1, 6.3]}
|
||||
group_by(['one', 'two', 'three'], len) # {3: ['one', 'two'], 5: ['three']}
|
||||
```
|
||||
|
||||
@ -14,5 +14,4 @@ def n_times_string(s, n):
|
||||
|
||||
```py
|
||||
n_times_string('py', 4) #'pypypypy'
|
||||
|
||||
```
|
||||
@ -5,7 +5,6 @@ tags: list,math,intermediate
|
||||
|
||||
Creates a list of elements, grouped based on the position in the original lists.
|
||||
|
||||
|
||||
Use `max` combined with `list comprehension` to get the length of the longest list in the arguments.
|
||||
Loop for `max_length` times grouping elements.
|
||||
If lengths of `lists` vary, use `fill_value` (defaults to `None`).
|
||||
|
||||
Reference in New Issue
Block a user