Coconut

Coconut is a simple, elegant, Pythonic functional programming language that compiles to Python. Since all valid Python is valid Coconut, joining the over 30,000 people already using Coconut will only extend and enhance what you're already capable of in Python.

Why use Coconut? Coconut is built to be fundamentally useful. Coconut enhances the repertoire of Python programmers to include the tools of modern functional programming, in such a way that those tools are easy to use and immensely powerful; that is, Coconut does to functional programming what Python did to imperative programming. And Coconut code runs the same on any Python version, making the Python 2/3 split a thing of the past.

Installing Coconut is as easy as

  1. installing Python,
  2. opening a command-line prompt,
  3. and entering:
python -m pip install coconut

which will give you access to all the features of Coconut, which adds to Python built-in, syntactical support for:

"hello, world!" |> print
(x) -> x ** 2
range(10) |> map$((x) -> x ** 2) |> list
match [head] + tail in [0, 1, 2, 3]:
    print(head, tail)
{"list": [0] + rest} = {"list": [0, 1, 2, 3]}
5 `mod` 3 == 2
data vec2(x, y):
    def __eq__(self, other):
        match vec2(=self.x, =self.y) in other:
            return True
        else:
            return False
range(15) |> map$((*)$(2)) |> list
f .. g .. h (x, y, z)
(| first_elem() |) :: rest_elems()
range(100) |> parallel_map$((**)$(2)) |> list
@recursive
def factorial(n):
    case n:
        match 0:
            return 1
        match _ is int if n > 0:
            return n * factorial(n - 1)

and much more!

Ready to get started? Here are some links to help you out: