没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
www.trustie.net/open_source_projects | 主页 > 开源项目社区 > fusion-lang |
fusion-lang
|
0 | 0 | 19 |
贡献者 | 讨论 | 代码提交 |
Fusion is a powerful high level programming language that merges several feature from Ruby, Python, Java, C++, Haskell, Pascal, Visual Basic, in a only language.
It’s implemented by a compiler written in Haskell that transform Fusion code in Ruby code. It’s probable that in the near future the code will be compiled in various agile programming languages, like Python or PHP.
However, at the moment we’re focusing the attention only on Ruby.
Sample program written in FusionImplementations of URM machine, see Computability, Nigel Cutland.
function prime(n)
# The exponent of the prime number 2 in the expansion of n
e = 0
while n % 2 == 0: n >>= 1; ++e
return e
- Pairs of naturals (NxN)
function p(m, n): return 2**m * (2*n + 1) - 1
function p1(x): return prime (x + 1)
function p2(x): return ((x + 1) / 2 ** p1 x - 1) / 2
- Positive naturals cubics (N+)^3
function z(m, n, q): return p (p (m - 1) (n - 1)) (q - 1)
function z1(x): return p1 (p1 x) + 1
function z2(x): return p2 (p1 x) + 1
function z3(x): return p2 x + 1
- Naturals tuple (arity > 0)
function t(a)
x = s = 0
for i in 0...a.length:
s += a[i]
x += 2 ** (s + i)
return x - 1
function t_inv(x)
b = [] # digits 1 in the binary representation of x + 1
t = [] # partial result
n = 0
++x
while x > 0
if x % 2 == 1
b << n++
i = b.length - 1
t << b[i] - (i == 0 ? 0 : b[i - 1] + 1)
x /= 2
return t
- URM instructions
class Z(n)
function to_s: return "Z(#{@n})"
function b: return 4 * (@n - 1)
class S(n)
function to_s: return "S(#{@n})"
function b: return 4 * (@n - 1) + 1
class T(m, n)
function to_s: return "T(#{@m}, #{@n})"
function b: return 4 * p (@m - 1) (@n - 1) + 2
class J(m, n, q)
function to_s: return "J(#{@m}, #{@n}, #{@q})"
function b: return 4 * z @m @n @q + 3
function b_inv(x)
r = x % 4
u = (x - r) / 4
case r
when 0: return Z (u + 1)
when 1: return S (u + 1)
when 2: return T (p1 u + 1) (p2 u + 1)
return J (z1 u) (z2 u) (z3 u)
- URM programs (P = list of instructions)
function g(P): return t [I.b for I in P]
function g_inv(n): return [b_inv x for x in t_inv n]
procedure print_program(P)
for I in P: print I
procedure main
P = [ new T(1,3),
new S(4),
new Z(6) ]
n = g P
print_program (g_inv n) # g_inv n == P
print nYou can find all documentation in http://develbook.com.