TypeCast/MaximKornilov | TypeCast/JuliaZ | ||||
---|---|---|---|---|---|
f | 1 | from functools import wraps | f | 1 | from functools import wraps |
2 | 2 | ||||
3 | 3 | ||||
n | 4 | def cast(cast_type): | n | 4 | def cast(type): |
5 | def functional(func): | ||||
6 | @wraps(func) | ||||
7 | def argument(*args): | ||||
8 | return type(func(*args)) | ||||
5 | 9 | ||||
n | 6 | def decorator(f): | n | 10 | return argument |
7 | 11 | ||||
n | 8 | @wraps(f) | n | 12 | return functional |
9 | def wrapper(*args): | ||||
10 | 13 | ||||
t | 11 | return cast_type(f(*args)) | t | ||
12 | |||||
13 | return wrapper | ||||
14 | return decorator | ||||
15 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|