Sponsored links: Algebra eBooks
 

Related

cons-let

:lisp (defun pairs (i...

:lisp (pairs '(1 2 3 ...

:lisp (let ((seq '(1 ...

Calculate

cons-if-labels-let

:lisp (defun r (n) (l...

Calculate

cons-if-lambda-let-or-unless

:lisp (defun lottery ...

:lisp (lottery);

:lisp (lottery t);

Calculate

cons-if

:lisp (defun nodes-de...

:lisp (nodes-deep '(a...

:lisp (setq tree '(a ...

Calculate

cons-let

:lisp (defun pairs (i...

:lisp (pairs '(1 2 3 ...

pairs([1, 2, 3, 4, 5]);

Calculate

cons-if-lambda-length-rest-reverse

:lisp (defun enum-int...

:lisp (enum-interval ...

:lisp (reduce '+ (enu...

Calculate

cons-first-rest

_append_(A, B) := if ...

endcons2(A, x) := _ap...

endcons2([2,3,4], 6);

Calculate

cons-if-lambda-let-unless

:lisp (defun lottery ...

:lisp (lottery);

:lisp (lottery t);

Calculate

cons-first-rest

_append_(A, B) := if ...

_append_([1,2,3],[7,8...

Calculate

cons-if-lambda-let-or-unless

:lisp (defun lottery ...

:lisp (lottery);

:lisp (lottery t);

Calculate

cons

Run Example
(%i1):lisp (defun r (n) (labels ((f (k l z) (let ((ln (+ (* 1.003 l) (* 0.006 z))) (zn (+ (* 0.0069 l) (* 1.026 z)))) (if (<
 k n) (f (1+ k) ln zn) (cons (/ ln l) (/ zn z)))) (f 0 10 1000))))) (print (r 100));

NIL 
NIL
(%i1) 
Run Example
kill(lastdigits,pidigits, a, b);
(%o1)                                done
(%i2) ratprint:false;
(%o2)                                false
(%i3) pidigits(prec):=block([fpprec:prec+1], ratprint:false, bftorat:false, ratepsilon:2.0e-16, float2bf:false, ans:float((%pi-mod(%pi, 10^(-prec)))), return(ans));
(%o3) pidigits(prec) := block([fpprec : prec + 1], ratprint : false, 
bftorat : false, ratepsilon : 2.0E-16, float2bf : false, 
                             - prec
ans : float(%pi - mod(%pi, 10      )), return(ans))
(%i4) lastdigits(fnum, lastn):=block([m:rat(fnum), n:lastn, ans], /* it doesn't help when lastn is bigger than the total digits in fnum it returns the whole digits in fnum anyway without erroring! and fnum=%pi stuff works only upto 8 digits cause num(rat(fnum)) has somuch only! */ratprint:false, ratio(num):=block([k, a], ratprint:false, for k:1 thru fpprec do (a:10^k/ratdenom(num), if(integerp(a)) then return(a))), ratepsilon:2.0e-16, bftorat:false,  ans:mod(ratio(fnum)*num(m), (10^n))/(ratio(fnum)*denom(m)), return(float(ans)));
(%o4) lastdigits(fnum, lastn) := block([m : rat(fnum), n : lastn, ans], 
ratprint : false, ratio(num) := block([k, a], ratprint : false, 
                                 k
                               10
for k thru fpprec do (a : -------------, if integerp(a) then return(a))), 
                          ratdenom(num)
                                                                       n
                                             mod(ratio(fnum) num(m), 10 )
ratepsilon : 2.0E-16, bftorat : false, ans : ----------------------------, 
                                                 ratio(fnum) denom(m)
return(float(ans)))
(%i5) lastdigits(4.1459, 5);
(%o5)                          4.14590001103631
(%i6) lastdigits(3.1459, 3);
(%o6)                               0.0459
(%i7) b:pidigits(5);
(%o7)                               3.14159
(%i8) lastdigits(3.14159, 3);
(%o8)                               0.00159
(%i9) lastdigits(pidigits(5), 3);
(%o9)                               0.00159
(%i10) pidigits(6);
(%o10)                             3.141592
(%i11) lastdigits(pidigits(6), 3);
(%o11)                       5.9199999999999997E-4
(%i12) lastdigits(4.14592, 3);
(%o12)                              0.00592
(%i13) lastdigits(b, 3);
(%o13)                              0.00159
(%i14) a:[0, float(%pi)];
(%o14)                      [0, 3.141592653589793]
(%i15) a;
(%o15)                      [0, 3.141592653589793]
(%i16) delete(pidigits(16), a);
(%o16)                                [0]
(%i17) delete(pidigits(fpprec), a);
(%o17)                                [0]
(%i18) delete(pidigits(fpprec), [0, float(%pi)]);
(%o18)                                [0]
(%i19) intervals(items, [granul]):=block([ start:first(items), stop:last(items), ans:[], granul:(if not(emptyp(granul)) then first(granul) else 1) ], ratprint:false, if (emptyp(items)) then [] elseif(listp(items)) then    if(emptyp(rest(items))) then []     else     while(float(rat(start))<
float(rat(stop))) do    (ans:delete([],             delete([float(rat(stop)), float(rat(stop+granul))],             if(float(rat(start+granul))>
float(rat(stop)))            then return() else            append(ans, [cons(float(rat(start)),  [float(rat(start+granul))])]))),      start:float(rat(start+granul))),     return(ans));
(%o19) intervals(items, [granul]) := block([start : first(items), 
stop : last(items), ans : [], granul : 
if not emptyp(granul) then first(granul) else 1], ratprint : false, 
if emptyp(items) then [] elseif listp(items)
 then (if emptyp(rest(items)) then [] else (while float(rat(start)) < 
float(rat(stop)) do (ans : delete([], delete([float(rat(stop)), 
float(rat(stop + granul))], if float(rat(start + granul)) > float(rat(stop))
 then return() else append(ans, [cons(float(rat(start)), 
[float(rat(start + granul))])]))), start : float(rat(start + granul))))), 
return(ans))
(%i20) intervals([0, 2*%pi], %pi);
(%o20) [[0.0, 3.141592653589793], [3.141592653589793, 6.283185307179585]]
(%i21) delete(pidigits(fpprec), intervals([0, 2*%pi], %pi));
(%o21) [[0.0, 3.141592653589793], [3.141592653589793, 6.283185307179585]]
(%i22) 
Run Example
cons(X, [[1],[2],[3]]);
(%o1)                         [X, [1], [2], [3]]
(%i2) 
[append,block,cons,delete,do,emptyp,first,float,lambda,last,listp,load,makelist,numberp,ratprint,rest,return,reverse] [append,block,cons,delete,do,emptyp,first,float,lambda,last,listp,load,map,ratprint,rest,return,reverse] [append,block,cons,delete,do,emptyp,first,float,last,listp,ratprint,rest,return] [append,block,cons,delete,do,emptyp,first,float,last,listp,ratprint,rest] [append,block,cons,emptyp,find_root,first,flatten,floor,if,kill,last,listp,makelist,not,rest,second,sin] [append,block,cons,emptyp,first,flatten,floor,if,kill,last,listp,makelist,not,rest,second] [append,block,cons,emptyp,first,flatten,floor,if,kill,listp,makelist,not,rest,second] [append,block,cons,equal,if,not,return] [append,block,cons,equal,if,return] [append,block,cons,return] [append,cons,if,let,quotient] [append,cons,if,let,reverse] [append,cons,if,let] [append,cons,lambda,let,string,values] [append,cons,lambda,let] [apply,at,block,cons,flatten,if,listp,piece] [apply,block,ceiling,cons,do,fpprec,rationalize,ratnump,reverse,sin] [apply,cons,lambda,last,let,sum] [apply,cons,lambda,last,let] [apply,cons,lambda,let,values] [apply,cons,lambda,let] [assume,cons,eliminate,ev,fpprintprec,map,plot2d,solve] [at,block,cons,if,listp,piece] [bftorat,block,cons,delete,do,emptyp,first,float2bf,fpprec,lambda,last,listp,map,maplist,mod,ratepsilon,ratprint,rest,return,second] [bftorat,block,cons,delete,do,emptyp,first,float2bf,fpprec,lambda,last,listp,map,maplist,mod,ratepsilon,ratprint,rest,return] [bftorat,block,cons,delete,do,emptyp,first,float2bf,fpprec,lambda,last,listp,map,mod,ratepsilon,ratprint,rest,return] [bftorat,block,cons,delete,emptyp,false,first,float2bf,fpprec,if,integerp,kill,lambda,listp,map,mod,ratdenom,ratepsilon,ratprint,rest,return] [block,cons,delete,do,emptyp,first,float,if,last,length,listp,not,ratprint,rem,rest] [block,cons,delete,do,emptyp,first,float,if,last,length,listp,ratprint,rem,rest] [block,cons,diff,lambda,scanmap] [block,cons,emptyp,first,if,kill,listp,makelist,rest,second] [block,cons,lambda,scanmap] [block,cons,linsolve,simp] [col,cons,endcons,genmatrix,kill,min,permanent,print,random,row,sort,sqrt,transpose] [cons,divsum,do,length,member,print] [cons,do,mod] [cons,eliminate,ev,fpprintprec,map,plot2d,solve] [cons,endcons,plot2d] [cons,first,length,rest] [cons,first,rest] [cons,if,labels,let,print] [cons,if,labels,let] [cons,if,lambda,length,rest,reverse] [cons,if,lambda,let,or,unless] [cons,if,lambda,let,unless] [cons,if] [cons,lambda,let,subst] [cons,lambda,let] [cons,let] [cons]

Related Help

Help for Cons