If you want to switch to Python-based languages (even if they are not strictly Python), then you might like Coconut.
Cocunut adds several functions for functional programming in Python, including pattern matching.
case [1,2,3]:
match (a,b,c):
print((c,b,a))
case [1,2,3]:
match (1,) + a:
print(a)
case [1,2,3]:
match (1,) + a if len(a) == 3:
print(a)
else:
print("else")
case [1,2,3,4]:
match (1,) + a if len(a) == 3:
print(a)
else:
print("else")
case [1,2,3,4,5]:
match (1,) + a + (5,) if len(a) == 3:
print(a)
else:
print("else")
source
share