-- File of Currently active and recently fixed interpreter bugs

--- eval a polynomial with EXPR substitution values
--- Fixed by SCM, verified on 10/30/90

)clear all


eq1:= A*x**2 + B*x*y + C*y**2 +D*x + E*y + F

eq2:= eval(eq1,[x= xdot*cos(t) - ydot*sin(t), y=xdot*sin(t) + ydot*cos(t)])

-- UTS coercions.  Fixed by SCM, verified on 10/30/90

)clear all

taylor exp x

s := %

s::(UTS(EXPR FLOAT, x, 0))
s::(UTS(FLOAT, x, 0))

eval(s,1)
%::(Stream Float)

-- overloading interpreter maps on arity
--- Fixed by SCM, verified on 10/30/90

)clear all

f(x) == x+1
f(x,y) == x+y

f 3
f(3,4)
f(5)
f(1,x)

-- targetted function requiring a coercion
--- Fixed by SCM, verified on 10/30/90

)clear all
series(n +-> bernoulli(n)/factorial(n), t=0)

-- in-homogeneous list mapping
--- Fixed by SCM, verified on 10/30/90

)clear all
l := [1,2,-1]
f : INT -> FRAC INT
f x == x
map(f, l)

-- Function args to interpreter functions
--- Fixed by SCM, verified on 10/30/90

)cl all
f: INT -> INT
f x == x+1
u g == g 3
u f

-- category modemap requiring a field to be constructed
--- Fixed by SCM, verified on 10/30/90

)clear all

groebner [x**2 - y, y**3+1]

-- operations requiring polynomials, passed variables
--- Fixed by SCM, verified on 10/30/90

)clear all
factor x

-- bracket parsing and empty-set types
--- Fixed by SCM, verified on 10/30/90

)clear all
{}$(List INT)
{1}

-- Shouldn't work, but no longer bombs the interpreter
--- Fixed by SCM, verified on 10/30/90

)clear all
map(variable, [x,y])

-- Recursive map type analysis bug
--- Fixed by SCM, verified on 10/30/90
)set fun recur off
)clear all

p(n,x) == if n=0 then 1 else (x+n-1)*p(n-1,x)
pp(n,x) == if n=0 then 1 else if n<0 then (-1)**n/p(-n,1-x) else p(n,x)
pp(-1,x) -- should be 1/(x-1)

-- interpret-code mode for iterators is broken

)cl all
f n ==
  for i in 1..n repeat
    j:=2*i
    m:SQMATRIX(j,?):=1
    print m
g n ==
    j:=2*n
    m:SQMATRIX(j,?):=1
    print m

g 3 -- Should work
f 3 -- Bombs

-- Test interpreter list destructuring

)clear all
mp(x,l) ==
  l is [a,:b] =>
    a*x**(#b)+ mp(x,b)
  0

mp(x, [1,3,4, 2])
mp(x, [1,2,-3, 4])

-- Tests compilation of recursive functions

)clear all

f1 n ==
  if n=0 then 1 else if n=1 then 1 else f1(n-1)+f1(n-2)
 
f2 n ==
  m:=n
  if n=0 then 1 else if n=1 then 1 else f2(n-1)+f2(n-2)
 
f3 n ==
  n=0 => 1
  n=1 => 1
  f3(n-1)+f3(n-2)
 
f4 n ==
  m:=n
  n=0 => 1
  n=1 => 1
  m:=n
  f4(n-1)+f4(n-2)
 
f5 n == if n=0 or n=1 then 1 else f5(n-1)+f5(n-2)
 
[f1 3,f2 3, f3 3,f4 3,f5 3]
