Falcon

Implementation of programming language Falcon

The original (and the only) implementation of the language, developed by Giancarlo Niccolai and Falcon Committee.

Examples:

Hello, World!:

Example for versions Falcon 0.9.6.6
printl('Hello, World!')

Factorial:

Example for versions Falcon 0.9.6.6

This example uses iterative factorial calculation.

fact = 1
for i in [0:16]
    printl (i, "! = ", fact)
    fact *= (i+1)
end

Factorial:

Example for versions Falcon 0.9.6.6

This example uses recursive factorial calculation.

function fact(n)
    if n==0: return 1
    return n * fact(n-1)
end

for i in [0:16]
    printl (i, "! = ", fact(i))
end

Fibonacci numbers:

Example for versions Falcon 0.9.6.6

This example uses recursive definition of Fibonacci numbers.

function fib(n)
    if n <= 2 :  return 1
    return fib(n-1) + fib(n-2)
end

for i in [1:17]
    print (fib(i), ", ")
end
printl ("...")

CamelCase:

Example for versions Falcon 0.9.6.6

This program processes the input string character by character.

text = input().lower()
cc = ""
was_space = true
for i in [ 0 : text.len() ]
    if text[i] >= 'a' and text[i] <= 'z'
        if was_space
            cc += text[i].upper()
        else
            cc += text[i]
        end
        was_space = false
    else
        was_space = true
    end
end
printl(cc)

Quadratic equation:

Example for versions Falcon 0.9.6.6
a = int(input())
if a == 0
    printl("Not a quadratic equation.")
    exit()
end
b = int(input())
c = int(input())
d = b ** 2 - 4 * a * c
if d == 0
    printl("x = " + (-b / 2.0 / a))
else 
    if d > 0 
        printl("x1 = " + ((-b + d**0.5) / 2.0 / a))
    	printl("x2 = " + ((-b - d**0.5) / 2.0 / a))
    else
        printl("x1 = (" + (-b / 2.0 / a) + "," + ((-d)**0.5 / 2.0 / a) + ")")
        printl("x2 = (" + (-b / 2.0 / a) + "," + (- ((-d)**0.5 / 2.0 / a)) + ")")
    end
end