How to print the values of a recursive function



Try removing each 'return' from your code. That will eliminate the syntax errors in the function Character.
Also,  Robert mentioned this, but a hasharry and function both named Character might be OK, but it's confusing.

Likely Fundamental1 and Fundamental1 should be quoted.

The user documentation for 'return'  maybe isn't as clear as it should be; here are three examples:

Syntax error:

  (%i3) f(x) := return x;
   incorrect syntax: X is not an infix operator

Bogus:

  (%i3) g(x) := return(x);
  (%o3) g(x):=return(x)

   (%i4) g(42);
    return: not within 'block'

OK:

   (%i5) h(x) := block([], return(x));
   (%o5) h(x):=block([],return(x))

   (%i6) h(42);
   (%o6) 42


--Barton
________________________________


I would like to print a value of a recursive function. For example, Character(1, 2, 1, 1). But the following codes doesn't work. I don't know where is the problem. Thank you very much.

Best wishes,
Jianrong.



   for k:0 thru 20 step 1 do
         for n:0 thru 20 step 1 do
              for l:0 thru 20 step 1 do
                        Character[m*21*21*21+k*21*21+n*21+l]:0;

Character(m, k, n, l):= block([],
if (Character[m*21*21*21+k*21*21+n*21+l] > 0 ) then (Character[n*21*21*21+k*21*21+m*21+l]:Character[m*21*21*21+k*21*21+n*21+l], Character[m*21*21*21+l*21*21+n*21+k]:Character[m*21*21*21+k*21*21+n*21+l], Character[n*21*21*21+l*21*21+m*21+k]:Character[m*21*21*21+k*21*21+n*21+l], return Character[m*21*21*21+k*21*21+n*21+l] )
else if (m=0 and k=0 and n=0 and l=0) then return 1
else if ((m=1 and k=0 and n=0 and l=0) or ((m=0 and k=0 and n=1 and l=0)) ) then return Fundamental1
else if ((m=0 and k=1 and n=0 and l=0) or ((m=0 and k=0 and n=0 and l=1)) ) then return Fundamental2
else if (m>0 and k>0 and n>0 and l>0) then return (Character(m-1, k, n, l)*Character(m, k, n, l-1)-Character(0, 2*m-1, floor(k/2), 0)*Character(floor(k/2), 2*n, 0, 0))/(Character(m-1, k, n, l-1))
else if (m>0 and k>0 and n>0 and l=0) then return (Character(m-1, k, n, 0)*Character(m, k, n-1, 0)-Character(0, 2*m-1, floor(k/2), 0)*Character(floor(k/2), 2*n-1, 0, 0))/(Character(m-1, k, n-1, 0))
else if (m>0 and k>0 and n=0 and l=0) then return (Character(m-1, k, 0, 0)*Character(m, k-1, 0, 0)-Character(floor(k/2), 2*m-1, 0, 0)*Character(floor((k-1)/2), 0, 0, 0))/(Character(m-1, k-1, 0, 0))
else if (m>0 and k=0 and n=0 and l=0) then return (Character(m-1, 0, 0, 0)*Character(m-1, 0, 0, 0)-Character(0, 2*(m-1), 0, 0))/(Character(m-2, 0, 0, 0))
else if (m=0 and k>0 and n=0 and l=0) then return (Character(0, k-1, 0, 0)*Character(0, k-1, 0, 0)-Character(floor((k-1)/2), 0, 0, 0)*Character(floor(k/2), 0, 0, 0))/(Character(0, k-2, 0, 0))
);