Haskell does something similar to this..
ls :: [String]
ls = [“hello”, “world”]
t :: (String, Int)
t = (“hello”, 5)
While at it, why don’t we pattern match function parameters like Haskel. Very
elegant way for function overload.
Something like this …
case def func(int(x), [float(y), *_
On Sun, Aug 01, 2021 at 07:42:07PM +0400, Abdulla Al Kathiri wrote:
> While at it, why don’t we pattern match function parameters like
> Haskel. Very elegant way for function overload.
I don't think your example is very elegant:
> case def func(int(x), [float(y), *_], int(z)) if z != 0 -> int:
Yeah just switch between case and match.
def func(x, alist, z): # Type-hints remain optional.
"""Docstring goes here"""
match (x, alist, z):
case (int(x), [float(y), _], 0):
return 0
case (int(x), [float(y), _], int(z)):
return int(