Skip to content

Каррирование#11

Open
EStarikov wants to merge 3 commits intomainfrom
curry_func
Open

Каррирование#11
EStarikov wants to merge 3 commits intomainfrom
curry_func

Conversation

@EStarikov
Copy link
Owner

No description provided.

@EStarikov EStarikov requested a review from chernishev October 26, 2025 13:20
Copy link

@Godrik0 Godrik0 left a comment

Choose a reason for hiding this comment

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

Если ослабить проверку на n, то стоит еще проверить:
Что n -- это целое число;
Что n -- неотрицательное.

Comment on lines 19 to 23
def uncurried(*args):
result = func
for arg in args:
result = result(arg)
return result
Copy link

Choose a reason for hiding this comment

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

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

src/curry.py Outdated
def curry(func, n):
if n != func.__code__.co_argcount:
raise Exception("неправильная арность")
return
Copy link

Choose a reason for hiding this comment

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

После raise выполнение функции прекращается

src/curry.py Outdated

def curry(func, n):
if n != func.__code__.co_argcount:
raise Exception("неправильная арность")
Copy link

Choose a reason for hiding this comment

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

Использовать Exception -- плохая практика, лучше указывать конкретную ошибку, например ValueError



def curry(func, n):
if n != func.__code__.co_argcount:
Copy link

Choose a reason for hiding this comment

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

n != func.__code__.co_argcount не позволит нам выполнить частичной каррирование.
Достаточно проверить, что n не больше реального количества аргументов

EStarikov and others added 2 commits December 20, 2025 10:50
… нужно передавать правильно, частичное каррирование реализовано с помощью args1, который фиксирует параметры заранее
return a + b + c


def curry(func, n, *args1):
Copy link

Choose a reason for hiding this comment

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

curry принимает функцию и её арность

У Вас еще можно передать аргументы, что немного странно


def curry(func, n, *args1):
if n != func.__code__.co_argcount:
raise ValueError
Copy link

Choose a reason for hiding this comment

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

Стоит писать текст ошибок, без них вообще не понятно из-за чего упала программа

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