Skip to content

add functions for task on functional programming#9

Open
ipsemenov wants to merge 1 commit into
mainfrom
functional_programming
Open

add functions for task on functional programming#9
ipsemenov wants to merge 1 commit into
mainfrom
functional_programming

Conversation

@ipsemenov
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown

@krglkvrmn krglkvrmn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В целом хорошо, но возникла путаница с назначением функций, комментарии ниже

Comment thread hw6/functional.py

funcs = args[:-1]
lst = args[-1]
lst = func_chain(*funcs)(lst)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Функции нужно было применять к каждому элементу контейнера, а не к контейнеру целиком, она же называется map

Comment thread hw6/functional.py
return lst


def conditional_reduce(func_1, func_2, lst):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А эта функция уже должна делать reduce, причём сама. Тут же ты перекладываешь ответственность за это на func_2

Comment thread hw6/functional.py
Comment on lines +100 to +105
def partial(func, *args, **kwargs):
def newfunc(*fargs, **fkwargs):
newkwargs = kwargs.copy()
newkwargs.update(fkwargs)
return func(*fargs, **newkwargs)
return newfunc
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно объявить её отдельно, чтобы избежать очень высокого уровня вложенности

Comment thread hw6/functional.py
'''
Wrapper around func_chain function. Makes consistent application of functions
passed into decorator function - func_chain.
:param args: positional arguments
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В твоём случае args это 1 аргумент

Suggested change
:param args: positional arguments
:param args: positional argument

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants