What is the functional language on .NET framework? F#.
What are the functional language on JVM? Scala, Kotlin, Clojure, etc.
What is the functional language for Python? You have Coconut!
A quick taste:
What are you waiting for? Try Coconut!
pip install coconut
And don't forget to donate and/or contribute to Coconut's development!
What are the functional language on JVM? Scala, Kotlin, Clojure, etc.
What is the functional language for Python? You have Coconut!
A quick taste:
- pipeline-style programming
"hello, world!" |> print
- prettier lambdas
x -> x ** 2
- partial application
range(10) |> map$(pow$(?, 2)) |> list
- pattern-matching
match [head] + tail in [0, 1, 2, 3]:
print(head, tail)
- destructuring assignment
{"list": [0] + rest} = {"list": [0, 1, 2, 3]}
- infix notation
5 `mod` 3 == 2
- operator functions
product = reduce$(*)
- function composition
(f..g..h)(x, y, z)
- lazy lists
(| first_elem() |) :: rest_elems()
- parallel programming
range(100) |> parallel_map$(pow$(2)) |> list
- tail call optimization
def factorial(n, acc=1):
case n:
match 0:
return acc
match _ is int if n > 0:
return factorial(n-1, acc*n)
- algebraic data types
data Empty()
data Leaf(n)
data Node(l, r)
def size(Empty()) = 0
@addpattern(size)
def size(Leaf(n)) = 1
@addpattern(size)
def size(Node(l, r)) = size(l) + size(r)
pip install coconut
And don't forget to donate and/or contribute to Coconut's development!
No comments:
Post a Comment