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:
Angelos Chalaris
2020-01-03 12:52:39 +02:00
parent 9985c0f10f
commit cb8bbd9745
21 changed files with 32 additions and 34 deletions

View File

@ -17,5 +17,8 @@ def bifurcate_by(lst, fn):
``` ```
```py ```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'] ]
``` ```

View File

@ -14,10 +14,7 @@ def check_prop(fn, prop):
```py ```py
check_age = check_prop(lambda x: x >= 18, 'age') check_age = check_prop(lambda x: x >= 18, 'age')
user = { user = {'name': 'Mark', 'age': 18}
'name': 'Mark',
'age': 18
}
check_age(user) # True check_age(user) # True
``` ```

View File

@ -14,7 +14,7 @@ def group_by(lst, fn):
``` ```
```py ```py
import math from math import floor
group_by([6.1, 4.2, 6.3], math.floor) # {4: [4.2], 6: [6.1, 6.3]} 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']} group_by(['one', 'two', 'three'], len) # {3: ['one', 'two'], 5: ['three']}
``` ```

View File

@ -14,5 +14,4 @@ def n_times_string(s, n):
```py ```py
n_times_string('py', 4) #'pypypypy' n_times_string('py', 4) #'pypypypy'
``` ```

View File

@ -5,7 +5,6 @@ tags: list,math,intermediate
Creates a list of elements, grouped based on the position in the original lists. 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. Use `max` combined with `list comprehension` to get the length of the longest list in the arguments.
Loop for `max_length` times grouping elements. Loop for `max_length` times grouping elements.
If lengths of `lists` vary, use `fill_value` (defaults to `None`). If lengths of `lists` vary, use `fill_value` (defaults to `None`).