Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,41 @@
include builtins\bigatom.e
constant NUM = 1, DEN = 2
type ba_frac(object r)
return sequence(r) and length(r)=2 and bigatom(r[NUM]) and bigatom(r[DEN])
end type
function ba_gcd(bigatom u, bigatom v)
bigatom t
u = ba_floor(ba_abs(u))
v = ba_floor(ba_abs(v))
while v!=BA_ZERO do
t = u
u = v
v = ba_remainder(t, v)
end while
return u
end function
function ba_frac_normalise(bigatom n, bigatom d)
bigatom g
if ba_compare(d,BA_ZERO)<0 then
n = ba_sub(0,n)
d = ba_sub(0,d)
end if
g = ba_gcd(n,d)
return {ba_idivide(n,g),ba_idivide(d,g)}
end function
function ba_frac_sub(ba_frac a, ba_frac b)
bigatom {an,ad} = a,
{bn,bd} = b
return ba_frac_normalise(ba_sub(ba_multiply(an,bd),ba_multiply(bn,ad)),ba_multiply(ad,bd))
end function
function ba_frac_mul(ba_frac a, ba_frac b)
bigatom {an,ad} = a,
{bn,bd} = b
return ba_frac_normalise(ba_multiply(an,bn),ba_multiply(ad,bd))
end function

View file

@ -0,0 +1,10 @@
sequence a = {}
for m=0 to 60 do
a = append(a,{ba_new(1),ba_new(m+1)})
for j=m to 1 by -1 do
a[j] = ba_frac_mul({ba_new(j),ba_new(1)},ba_frac_sub(a[j+1],a[j]))
end for
if a[1][1]!=BA_ZERO then
printf(1,"B(%2d) = %44s / %s\n",{m,ba_sprint(a[1][1]),ba_sprint(a[1][2])})
end if
end for