Added functional.py and README for hw6#8
Open
ibragimovaamina wants to merge 2 commits into
Open
Conversation
krglkvrmn
suggested changes
Dec 11, 2022
| # It returns list of results of sequential application of these functions to the collection of values. | ||
|
|
||
| def sequential_map(*args): | ||
| *functions, values = [*args] # unpacking input functions and collection of values |
There was a problem hiding this comment.
Эта конструкция немного избыточна
Suggested change
| *functions, values = [*args] # unpacking input functions and collection of values | |
| *functions, values = args # unpacking input functions and collection of values |
| while len(values) > 1: # if 0 or 1 input values, returning values immediately | ||
| values[1] = function(values[0], values[1]) | ||
| values = values[1:] | ||
| return values |
There was a problem hiding this comment.
На выходе мы получаем список из одного элемента, а нам нужен сам элемент, без списка
Comment on lines
+49
to
+53
| list_of_functions = [*args] | ||
| while len(list_of_functions) > 1: | ||
| list_of_functions[1] = wrapping_function(list_of_functions[0], list_of_functions[1]) | ||
| list_of_functions = list_of_functions[1:] | ||
| return list_of_functions[0] |
There was a problem hiding this comment.
Сложна, как насчёт
Suggested change
| list_of_functions = [*args] | |
| while len(list_of_functions) > 1: | |
| list_of_functions[1] = wrapping_function(list_of_functions[0], list_of_functions[1]) | |
| list_of_functions = list_of_functions[1:] | |
| return list_of_functions[0] | |
| def inner_func(obj): | |
| for func in args: | |
| obj = func(obj) | |
| return obj | |
| return inner_func |
| return lambda x: outer_func(inner_func(x)) | ||
|
|
||
| def func_chain(*args): | ||
| list_of_functions = [*args] |
There was a problem hiding this comment.
А зачем тут делать распаковку, в данному случае args уже read-to-use
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.