Sponsored links: Algebra eBooks
 

Related

numberp

numberp(%i);

Calculate

numberp

numberp(%i);

Calculate

numberp

Run Example
(%i1)list:[1, 2, false, 3, 4];
(%o1)                         [1, 2, false, 3, 4]
(%i2) n:is(false);
(%o2)                                false
(%i3) n:2;
(%o3)                                  2
(%i4) is(equal(n, false));
(%o4)                               unknown
(%i5) is(false, false);
(%o5)                                false
(%i6) map(lambda([x], if(numberp(x) and is(equal(x, false))) then x else []), ''list);
(%o6) [if unknown then 1 else [], if unknown then 2 else [], [], 
                          if unknown then 3 else [], if unknown then 4 else []]
(%i7) 
Run Example
list:[1, 2, false, 3, 4];
(%o1)                         [1, 2, false, 3, 4]
(%i2) n:is(false);
(%o2)                                false
(%i3) n:2;
(%o3)                                  2
(%i4) is(equal(n, false));
(%o4)                               unknown
(%i5) is(false, false);
(%o5)                                false
(%i6) (lambda([n], if(numberp(n) and is(equal(n, false))) then n else []), list);
(%o6)                         [1, 2, false, 3, 4]
(%i7) 
Run Example
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))],             append(ans, [cons(float(rat(start)),  [float(rat(start+granul))])]))),      start:float(rat(start+granul))),     return(ans));
(%o1) 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))], append(ans, 
[cons(float(rat(start)), [float(rat(start + granul))])]))), 
start : float(rat(start + granul))))), return(ans))
(%i2) lsplit(fn, lst):=block([ acc:[], m:[], src:lst], load(basic),while (not(emptyp(src))) do (if(fn(first(src))) then return() else push(pop(src), acc)), push(src, m), return([reverse(acc), first(m)]));
(%o2) lsplit(fn, lst) := block([acc : [], m : [], src : lst], load(basic), 
while not emptyp(src) do if fn(first(src)) then return()
 else push(pop(src), acc), push(src, m), return([reverse(acc), first(m)]))
(%i3) lsplit(lambda([n], numberp(n)), intervals(makelist(n, n, -3, 3)));
define: warning: redefining the built-in function prog1
define: warning: redefining the built-in function symbolcheck
define: warning: redefining the built-in function push
define: warning: redefining the built-in function pop
define: warning: redefining the built-in function tr_ev
(%o3) [[[- 3.0, - 2.0], [- 2.0, - 1.0], [- 1.0, 0.0], [0.0, 1.0], [1.0, 2.0], 
                                                               [2.0, 3.0]], []]
(%i4) lsplit(lambda([n], listp(n)), intervals([-3, 3]));
define: warning: redefining the built-in function prog1
define: warning: redefining the built-in function push
define: warning: redefining the built-in function pop
define: warning: redefining the built-in function tr_ev
(%o4) [[], [[- 3.0, - 2.0], [- 2.0, - 1.0], [- 1.0, 0.0], [0.0, 1.0], 
                                                       [1.0, 2.0], [2.0, 3.0]]]
(%i5) lsplit(lambda([n], numberp(n)), intervals([-3, 3]));
define: warning: redefining the built-in function prog1
define: warning: redefining the built-in function push
define: warning: redefining the built-in function pop
define: warning: redefining the built-in function tr_ev
(%o5) [[[- 3.0, - 2.0], [- 2.0, - 1.0], [- 1.0, 0.0], [0.0, 1.0], [1.0, 2.0], 
                                                               [2.0, 3.0]], []]
(%i6) 

Related Help

Help for Numberp