Source code: github.com/gtr/ivy
Ivy is a statically typed functional programming language: friendly enough for beginners, robust enough for experienced programmers. Built to be inspected, reasoned about, and trusted.
Ivy is still a work-in-progress. There are many features that are yet to be implemented, but it's decently useful at the moment. Stay tuned for more!
-- Lists support pattern matching in function heads. fn length([]) => 0; fn length([_ :: tail]) => 1 + length(tail); fn map(f, []) => []; fn map(f, [head :: tail]) => f(head) :: map(f, tail); let numbers = [1, 2, 3, 4, 5]; let doubled = map(fn (x) => x * 2, numbers); println("Doubled: " ++ show(doubled));
-- Define a binary tree with a type parameter. type Tree<a> = | Empty | Node(a, Tree<a>, Tree<a>) ; fn count(Empty) => 0; fn count(Node(_, left, right)) => 1 + count(left) + count(right); let tree = Node(1, Node(2, Empty, Empty), Empty); println("Nodes: " ++ show(count(tree)));
_
(_)_ ___ _
| \ \ / / | | |
| |\ V /| |_| |
|_| \_/ \__, |
|___/ v0.2
Ivy - the friendly functional programming language
Type :help for commands, :q to quit
Ivy REPL Commands: :help, :h Show this help message :quit, :q Exit the REPL :reset, :r Reset interpreter state (clear all definitions) :load <path>, :l Load and execute a file :type <expr>, :t Show the inferred type of an expression :env Show all defined names in current scope Multi-line input is supported. The REPL will continue prompting with '...>' when it detects unclosed brackets or expressions.