2 ms·
I noted the in first example in the linked into - Python: def square(n): return n * n Pyret: fun square(n :: Number) -> Number: n * n
by tim333 10y ago
I noted the in first example in the linked into - Python:
def square(n):
return n * n
Pyret:
fun square(n :: Number) -> Number:
n * n
end
there's extra stuff. It also kind of loses the elegance of Python reading close to normal language - if you don't know programing but can do math you'd figure the first was define a function that gives a square but be confused what (n :: Number) -> Number: was about.
- jpolitz 10y agoThe type annotations are optional, so fun square(n): n * n end is a closer direct comparison to the Python program, for contexts that don't use annotations.