Skip to content

Curry uncurry task#5

Open
stuffacc wants to merge 1 commit intomainfrom
t6
Open

Curry uncurry task#5
stuffacc wants to merge 1 commit intomainfrom
t6

Conversation

@stuffacc
Copy link
Owner

No description provided.

@@ -0,0 +1,35 @@
def curry(func, max_args):
if max_args <= 0:
Copy link

Choose a reason for hiding this comment

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

А почему арность не может быть 0?

Comment on lines +2 to +3
if max_args <= 0:
raise ValueError('max_args must be a positive integer')
Copy link

Choose a reason for hiding this comment

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

Не проверяется случай, когда пользователь указывает арность не соответствующую реальной.
Мы можем написать f_curry = curry(sum3, 100), ошибка появится только при вызове функции f_curry.

Так же не проверяется, что max_args это int.

Comment on lines +18 to +23
def uncurry_next(*args):
current_func = curried_func
for arg in args:
current_func = current_func(arg)

return current_func
Copy link

Choose a reason for hiding this comment

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

Нет проверки количества переданных аргументов len(args) != max_args

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.

3 participants