in Lost & Found

Orcish programming

I’ve twittered about Orc. Orc is “a novel language for distributed and concurrent programming”. There are three combinators. Which allows function calls: parallel, sequential and pruning.
The presentation about Orc offered by them is a great introduction. It includes the motivation, these combinators and some examples.

def fib(0) = 0
def fib(1) = 1
def fib(n) = fib(n-1) + fib(n-2)

def fibs(0) = fib(1) | 0
def fibs(n) = fib(n) | fibs(n-1)

This program calculates the fibonacci numbers, as you can see. The special thing about is that it will return every number up to n.

fibs(10)
0
1
1
1
2
3
5
8
13
21
34
55

Now something cool. You want to calculate the factorial of this fibonacci numbers? No problem.

Firstly, you’ll need a function to calculate the factorial of a number n.

def fac(0) = 1
def fac(1) = 1
def fac(n) = fac(n-1) * n

Secondly, you use the combinator for sequential computing (>>).

fibs(10) > x > fac(x)
1
1
1
1
2
6
120
40320
6227020800
51090942171709440000
295232799039604140847618609643520000000
12696403353658275925965100847566516959580321051449436762275840000000000000

There’s a great short tutorial on Orc’s website. Also, there’s a online interpreter for testing short functions. Some examples are juicy like the load balancer.

Write a Comment

Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.