Skip to content

curry#3

Open
sugahu565 wants to merge 3 commits intomasterfrom
curry
Open

curry#3
sugahu565 wants to merge 3 commits intomasterfrom
curry

Conversation

@sugahu565
Copy link
Owner

No description provided.

@sugahu565 sugahu565 requested a review from chernishev October 26, 2025 20:42
@sugahu565 sugahu565 changed the title Add curry curry Oct 26, 2025


def uncurry(function, lenght_arg):
if lenght_arr < 0:
Copy link

Choose a reason for hiding this comment

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

lenght_arr кажется тут опечатка

@@ -0,0 +1,32 @@
def __curry(function, length_arg, args):
if length_arg < len(args):
raise Exception("too many arguments")
Copy link

Choose a reason for hiding this comment

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

Кидать общий класс Exception -- плохая практика. Нужно использовать более конкретные исключения.

Comment on lines +5 to +8
try:
return function(*args)
except:
raise Exception("invalid arguments or invalid number of arguments")
Copy link

Choose a reason for hiding this comment

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

Потенциально это может скрыть ошибку внутри полученной функции, например, деление на ноль и т.д.

Comment on lines +2 to +8
if length_arg < len(args):
raise Exception("too many arguments")
if length_arg == len(args):
try:
return function(*args)
except:
raise Exception("invalid arguments or invalid number of arguments")
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.

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