Related

flatten-solve

eq1:m*(2-m/3) = x;

flatten(solve(eq1, m));

Calculate

flatten

flatten([[2,3], [2,3]]);

Calculate

a:2;

b:3;

n:200;

Calculate

flatten

flatten([[2],2,3]);

Calculate

flatten-map-solve

Polynom:a*x^3+b*x^2+c...

f(x):=''Polynom;

g1:f(-5)=0;

Calculate

mean(map(rhs, flatten...

Calculate

flatten-matrix-solve

A:matrix([1,1,-1,1,2]...

B:[1,0,1,a,0];

L:flatten(A.[x1,x2,x3...

Calculate

mean(map(rhs, flatten...

Calculate

flatten

flatten([[2,3],2,3]);

Calculate

flatten-matrix-solve

A:matrix([1,1,-1,1,2]...

B:[1,0,1,a,0];

L:flatten(A.[x1,x2,x3...

Calculate

flatten

Run Example
```(%i1)intervals(items):=block([result],  result: if (emptyp(items)) then [] else           if(listp(items)) then          if(emptyp(rest(items))) then [] else          cons(cons(first(items),  [second(items)]),          intervals(rest(items))));
(%o1) intervals(items) := block([result],
result : if emptyp(items) then [] else (if listp(items)
then (if emptyp(rest(items)) then [] else cons(cons(first(items),
[second(items)]), intervals(rest(items))))))
(%i2) intervals(makelist(n, n, 1, 10));
(%o2) [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]
(%i3) intervals(makelist(n, n, 1, 11));
(%o3) [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9],
[9, 10], [10, 11]]
(%i4) ans:errcatch(find_root(sin(x), x, 2, 3));

find_root: function has same sign at endpoints: f(2.0) = 0.90929742682568,
f(3.0) = 0.14112000805987
(%o4)                                 []
(%i5) ans;
(%o5)                                 []
(%i6) seq(start,stop,stepping,[shift]) := block([                                            n, y:[],                                             shift: (if (not(emptyp(shift)))                                                         then float(first(shift))                                                            else (0.0))                                            ],            (n:floor((float(stop-start)/float(stepping)))),            (if (start <
stop)            then            (y:flatten(append([y],                                         makelist(float(start+shift+(stepping*(i-start))),                                         i, start, n+start))))            else            (y:flatten(append([y],                                         makelist(-(float(stop-shift-(stepping*(i-stop)))),                                         i, -(n+stop), stop)))))            (if (n>
1.0)                then return(y)                else return([])));
(%o6) seq(start, stop, stepping, [shift]) :=
block([n, y : [], shift : if not emptyp(shift) then float(first(shift))
float(stop - start)
else 0.0], n : floor(-------------------),
float(stepping)
if start < stop then y : flatten(append([y],
makelist(float(start + shift + stepping (i - start)), i, start, n + start)))
else y : flatten(append([y], makelist(- float(stop - shift
- stepping (i - stop)), i, - (n + stop), stop)))(if n > 1.0 then return(y)
else return([])))
(%i7) intervals(seq(0,7,1));
(%o7) [[0.0, 1.0], [1.0, 2.0], [2.0, 3.0], [3.0, 4.0], [4.0, 5.0], [5.0, 6.0],
[6.0, 7.0]]
(%i8) ans:[];
(%o8)                                 []
(%i9) %pi;
(%o9)                                 %pi
(%i10) %pi, numer;
(%o10)                         3.141592653589793
(%i11) 2*3.14159/%pi;
6.28318
(%o11)                              -------
%pi
(%i12) block([ans:[]], errormsg:false, for i in intervals(seq(0, 7, 1)) do ans:(append(ans, errcatch(find_root(sin(x), x, first(i), second(i))))), errormsg:true, return(ans));
(%o12)            [0.0, 3.141592653589793, 6.283185307179586]
(%i13) ```
Run Example
```seq(start,stop,stepping,[shift]) := block([                                            n, y:[],                                             shift: (if (not(emptyp(shift)))                                                         then float(first(shift))                                                            else (0.0))                                            ],            (n:floor((float(stop-start)/float(stepping)))),            (if (start <
stop)            then            (y:flatten(append([y],                                         makelist(float(start+shift+(stepping*(i-start))),                                         i, start, n+start))))            else            (y:flatten(append([y],                                         makelist(-(float(stop-shift-(stepping*(i-stop)))),                                         i, -(n+stop), stop)))))            (if (n>
1.0)                then return(y)                else return([])));
(%o1) seq(start, stop, stepping, [shift]) :=
block([n, y : [], shift : if not emptyp(shift) then float(first(shift))
float(stop - start)
else 0.0], n : floor(-------------------),
float(stepping)
if start < stop then y : flatten(append([y],
makelist(float(start + shift + stepping (i - start)), i, start, n + start)))
else y : flatten(append([y], makelist(- float(stop - shift
- stepping (i - stop)), i, - (n + stop), stop)))(if n > 1.0 then return(y)
else return([])))
(%i2) kill(pairs);
(%o2)                                done
(%i3) pairs(items):=block([result],result:if (emptyp(items)) then [] elseif (listp(items)) then     if(emptyp(rest(items))) then cons(last(items), []) else    cons(cons(first(items),  [second(items)]),                     [pairs(rest(rest(items)))]));
(%o3) pairs(items) := block([result], result :
if emptyp(items) then [] elseif listp(items)
then (if emptyp(rest(items)) then cons(last(items), [])
else cons(cons(first(items), [second(items)]), [pairs(rest(rest(items)))])))
(%i4) pairs([1, 2, 3, 4, 5]);
(%o4)                       [[1, 2], [[3, 4], [5]]]
(%i5) kill(pairs);
(%o5)                                done
(%i6) pairs(items):=block([result],result:if (emptyp(items)) then [] elseif (listp(items)) then     if(emptyp(rest(items))) then [last(items), []] else    cons(cons(first(items),  [second(items)]),                     [pairs(rest(rest(items)))]));
(%o6) pairs(items) := block([result], result :
if emptyp(items) then [] elseif listp(items)
then (if emptyp(rest(items)) then [last(items), []]
else cons(cons(first(items), [second(items)]), [pairs(rest(rest(items)))])))
(%i7) pairs([1, 2, 3, 4, 5]);
(%o7)                     [[1, 2], [[3, 4], [5, []]]]
(%i8) first(pairs(seq(1, 10, 1)));
(%o8)                             [1.0, 2.0]
(%i9) test([list]):=map(lambda([x], [first(x), second(x)]),list);
(%o9)    test([list]) := map(lambda([x], [first(x), second(x)]), list)
(%i10) find_root(sin(x), x, 0, %pi);
(%o10)                                0.0
(%i11) ```
Run Example
```load(functs);
(%o1)      /usr/share/maxima/5.21.1/share/simplification/functs.mac
(%i2) block([y:""], for i in (makelist(n, n, 1, 10)) do (y:flatten(append(makelist(i/100.0, i, i, i), [""]))), return(y));
(%o2)                               [0.1, ]
(%i3) ```

Help for Flatten