Mercurial > repos > rhope
view fib.rhope @ 183:24c6f8767190
Remove obsolete version of compiler that ran under the interpreter
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 27 Jul 2011 21:14:23 -0700 |
parents | a163250b8885 |
children |
line wrap: on
line source
/* This example program contains a naive implementation of the Fibonacci function While this isn't a particular fast way to implement the Fibonacci function it does parallize nicely */ //Here we define a worker Fib with one input named 'n' and one output named 'out' Fib[n:out] { //The If worker is one way to conditionally execute a piece of code If[[n] < [2]] { //This line will execute if [n] < [2] evaluates to Yes out <- 1 }{ //This line will execute if [n] < [2] evaluates to No //All Worker calls can be expressed in infix, postfix, or prefix notation //So [n]-[1] is the same as -[n,1] and [n,1]- out <- [Fib[[n]-[1]]] + [Fib[[n]-[2]]] } } Main[args] { //Here we get the first command line argument and convert it to a number n <- Int32[[args]Index[1]] //Call our Fib worker and Print the result to the terminal Print[Fib[n]] }