Origin for each line in Programming.red from check-in f2c04ccdad:

f2c04ccdad 2021-03-03    1: %%%%%%%%%%%%%%%%%%%%%
f2c04ccdad 2021-03-03    2: %  PROGRAMMING
f2c04ccdad 2021-03-03    3: %%%%%%%%%%%%%%%%%%%%%
f2c04ccdad 2021-03-03    4: 
f2c04ccdad 2021-03-03    5: % Define number to factorize
f2c04ccdad 2021-03-03    6: x:=42;
f2c04ccdad 2021-03-03    7: 
f2c04ccdad 2021-03-03    8: % Factorize x and write out each individual 
f2c04ccdad 2021-03-03    9: % factor
f2c04ccdad 2021-03-03   10: factors:=factorize(fix(x))$
f2c04ccdad 2021-03-03   11: x:=0$
f2c04ccdad 2021-03-03   12: for i:=1:length(factors) do begin
f2c04ccdad 2021-03-03   13:    q:=part(factors,i);
f2c04ccdad 2021-03-03   14:    for j:=1:part(q,2) do begin
f2c04ccdad 2021-03-03   15:       x:=x+1;
f2c04ccdad 2021-03-03   16:       write "factor ", x, ": ", part(q,1);
f2c04ccdad 2021-03-03   17:    end;
f2c04ccdad 2021-03-03   18: end;
f2c04ccdad 2021-03-03   19: 
f2c04ccdad 2021-03-03   20: % Procedure to calculate Legendre polynomial
f2c04ccdad 2021-03-03   21: % using recursion 
f2c04ccdad 2021-03-03   22: procedure p(n,x);
f2c04ccdad 2021-03-03   23:    if n<0 then rederr "Invalid argument to p(n,x)"
f2c04ccdad 2021-03-03   24:    else if n=0 then 1
f2c04ccdad 2021-03-03   25:    else if n=1 then x
f2c04ccdad 2021-03-03   26:    else ((2*n-1)*x*p(n-1,x)-(n-1)*p(n-2,x))/n$
f2c04ccdad 2021-03-03   27: 
f2c04ccdad 2021-03-03   28: % Enable fancy output
f2c04ccdad 2021-03-03   29: fancy_output$
f2c04ccdad 2021-03-03   30: 
f2c04ccdad 2021-03-03   31: % Calculate p(2,w)
f2c04ccdad 2021-03-03   32: write "P(2,w) = ", p(2,w);
f2c04ccdad 2021-03-03   33: 
f2c04ccdad 2021-03-03   34: % Incidentally, p(n,x) can be calculated more
f2c04ccdad 2021-03-03   35: % efficiently as follows
f2c04ccdad 2021-03-03   36: procedure p(n,x);
f2c04ccdad 2021-03-03   37:    sub(y=0,df(1/(y^2-2*x*y+1)^(1/2),y,n))/(for i:=1:n product i)$
f2c04ccdad 2021-03-03   38: 
f2c04ccdad 2021-03-03   39: write "P(3,w) = ", p(3,w);

iCAS Bundled REDUCE Scripts
Homepage | GitHub Mirror | SourceHut Mirror | NotABug Mirror | Chisel Mirror | Chisel RSS ]