Sponsored links: Algebra eBooks
 

Related

member

member(a,[b,c,d,a]);

Calculate

member

member(a,[b,c,d,a1]);

Calculate

member

member(a,[b,c,d,a]);

Calculate

member

member([true,true],[[...

Calculate

member

member(a,[b,c,d,a1]);

Calculate

member

member(4,[1,2,3,4]);

Calculate

member

member([true,true],[[...

Calculate

member

member([true,true],[[...

Calculate

member

member(a,[b,c,d,a1]);

Calculate

member

Run Example
(%i1)L:makelist(k^2,k,0,9);
(%o1)                [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
(%i2) member(81,L);
(%o2)                                true
(%i3) create_list(random(10),m,0,5);
(%o3)                         [2, 2, 4, 5, 4, 1]
(%i4) part(L,[6,5,1]);
(%o4)                             [25, 16, 0]
(%i5) 'A=A:matrix([1,2,3,4],[5,6,7,8],[9,10,11,12]);
                                 [ 1  2   3   4  ]
                                 [               ]
(%o5)                        A = [ 5  6   7   8  ]
                                 [               ]
                                 [ 9  10  11  12 ]
(%i6) a1=row(A,1);
(%o6)                         a1 = [ 1  2  3  4 ]
(%i7) a[1]=col(A,2);
                                       [ 2  ]
                                       [    ]
(%o7)                             a  = [ 6  ]
                                   1   [    ]
                                       [ 10 ]
(%i8) 'A=submatrix(1,A);
                                 [ 5  6   7   8  ]
(%o8)                        A = [               ]
                                 [ 9  10  11  12 ]
(%i9) 'A2=submatrix(A,2);
                                   [ 1  3   4  ]
                                   [           ]
(%o9)                         A2 = [ 5  7   8  ]
                                   [           ]
                                   [ 9  11  12 ]
(%i10) 'A12=submatrix(1,A,2);
                                    [ 5  7   8  ]
(%o10)                        A12 = [           ]
                                    [ 9  11  12 ]
(%i11) f[i,j]:=2*i+3*j;
(%o11)                        f     := 2 i + 3 j
                               i, j
(%i12) B1=B1:genmatrix(f,4,3);
                                   [ 5   8   11 ]
                                   [            ]
                                   [ 7   10  13 ]
(%o12)                        B1 = [            ]
                                   [ 9   12  15 ]
                                   [            ]
                                   [ 11  14  17 ]
(%i13) 
Run Example
L:makelist(k^2,k,0,9);
(%o1)                [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
(%i2) member(81,L);
(%o2)                                true
(%i3) create_list(random(10),m,0,5);
(%o3)                         [2, 2, 4, 5, 4, 1]
(%i4) part(L,[6,5,1]);
(%o4)                             [25, 16, 0]
(%i5) 'A=A:matrix([1,2,3,4],[5,6,7,8],[9,10,11,12]);
                                 [ 1  2   3   4  ]
                                 [               ]
(%o5)                        A = [ 5  6   7   8  ]
                                 [               ]
                                 [ 9  10  11  12 ]
(%i6) a1=row(A,1);
(%o6)                         a1 = [ 1  2  3  4 ]
(%i7) a[1]=col(A,2);
                                       [ 2  ]
                                       [    ]
(%o7)                             a  = [ 6  ]
                                   1   [    ]
                                       [ 10 ]
(%i8) 'A=submatrix(1,A);
                                 [ 5  6   7   8  ]
(%o8)                        A = [               ]
                                 [ 9  10  11  12 ]
(%i9) 'A2=submatrix(A,2);
                                   [ 1  3   4  ]
                                   [           ]
(%o9)                         A2 = [ 5  7   8  ]
                                   [           ]
                                   [ 9  11  12 ]
(%i10) 'A12=submatrix(1,A,2);
                                    [ 5  7   8  ]
(%o10)                        A12 = [           ]
                                    [ 9  11  12 ]
(%i11) f[i,j]:=2*i+3*j;
(%o11)                        f     := 2 i + 3 j
                               i, j
(%i12) B1=B1:genmatrix(f,4,3);
                                   [ 5   8   11 ]
                                   [            ]
                                   [ 7   10  13 ]
(%o12)                        B1 = [            ]
                                   [ 9   12  15 ]
                                   [            ]
                                   [ 11  14  17 ]
(%i13) 'D5=D5:diag_matrix(5,9,6,3,2,4);
                                [ 5  0  0  0  0  0 ]
                                [                  ]
                                [ 0  9  0  0  0  0 ]
                                [                  ]
                                [ 0  0  6  0  0  0 ]
(%o13)                     D5 = [                  ]
                                [ 0  0  0  3  0  0 ]
                                [                  ]
                                [ 0  0  0  0  2  0 ]
                                [                  ]
                                [ 0  0  0  0  0  4 ]
(%i14) 
Run Example
cut(l,m,k,h,[p]):=block( cut_segment(l, m, k, [p]):=block( elimn(l,index):=block([ans, indi:map("=", index, makelist(0, n, 1, length(index)))], ans:subst([0="_"], l*subst(indi, makelist(n, n, 1, length(l)))/makelist(n, n, 1, length(l))), if(not(emptyp(p))) then return(delete("_", ans)) else return(ans)), elimn(l, makelist(n, n, m, k))), cut_flanks(l, m, k, [p]):=block( elimn(l,index):=block([ans, indi:map("=", index, makelist(0, n, 1, length(index)))], ans:subst([0="_"], l*map(lambda([x], if(x=1) then 0 else 1), subst(indi, makelist(n, n, 1, length(l)))/makelist(n, n, 1, length(l)))), if(not(emptyp(p))) then return(delete("_", ans)) else return(ans)), elimn(l, makelist(n, n, m, k))), if(h=s and emptyp(p)) then return(cut_flanks(l,m,k)) else if(h=s and not(emptyp(p))) then return(cut_flanks(l,m,k,t)) else if(h=f and emptyp(p)) then return(cut_segment(l,m,k)) else if(h=f and not(emptyp(p))) then return(cut_segment(l,m,k,t)));
(%o1) cut(l, m, k, h, [p]) := block(cut_segment(l, m, k, [p]) := 
block(elimn(l, index) := block([ans, indi : 
map("=", index, makelist(0, n, 1, length(index)))], 
                       l subst(indi, makelist(n, n, 1, length(l)))
ans : subst([0 = "_"], -------------------------------------------), 
                              makelist(n, n, 1, length(l))
if not emptyp(p) then return(delete("_", ans)) else return(ans)), 
elimn(l, makelist(n, n, m, k))), cut_flanks(l, m, k, [p]) := 
block(elimn(l, index) := block([ans, indi : 
map("=", index, makelist(0, n, 1, length(index)))], 
ans : subst([0 = "_"], l map(lambda([x], if x = 1 then 0 else 1), 
subst(indi, makelist(n, n, 1, length(l)))
-----------------------------------------)), 
      makelist(n, n, 1, length(l))
if not emptyp(p) then return(delete("_", ans)) else return(ans)), 
elimn(l, makelist(n, n, m, k))), if (h = s) and emptyp(p)
 then return(cut_flanks(l, m, k)) else (if (h = s) and (not emptyp(p))
 then return(cut_flanks(l, m, k, t)) else (if (h = f) and emptyp(p)
 then return(cut_segment(l, m, k)) else (if (h = f) and (not emptyp(p))
 then return(cut_segment(l, m, k, t))))))
(%i2) find(s,l,h,[p]):=block([ans:[], rep:[], final:[], parts:makelist(part(l, makelist(n, n, 1+m, length(s)+m)), m, 0, length(l)-length(s)), res, count:0, pos:[]], for n:1 thru length(parts) do  (ans:append(ans, [map(lambda([x], if(is(x)) then lhs(x)), map("=", part(parts, n), s))])), for i in ans do (if(freeof(false, i)) then (res:i)), count:length(delete([], map(lambda([x], if(freeof(false, x)) then x else []), ans))), for i:1 thru length(ans) do (if(freeof(false, ans[i])) then pos:append(pos, [[i, i+length(ans[i])-1]])), if(h=f) then (if(not(emptyp(p))) then print(ans) else (print(res, ":", count), [pos])) else (for i in pos do (rep:append(rep, makelist(n, n, lmin(i), lmax(i)))), final:map(lambda([x], if(member(x, rep)) then l[x] else "_"), sublist_indices(l, atom)), return(final)));
(%o2) find(s, l, h, [p]) := block([ans : [], rep : [], final : [], 
parts : makelist(part(l, makelist(n, n, 1 + m, length(s) + m)), m, 0, 
length(l) - length(s)), res, count : 0, pos : []], 
for n thru length(parts) do ans : append(ans, 
[map(lambda([x], if is(x) then lhs(x)), map("=", part(parts, n), s))]), 
for i in ans do if freeof(false, i) then res : i, 
count : length(delete([], map(lambda([x], if freeof(false, x) then x else []), 
ans))), for i thru length(ans) do if freeof(false, ans )
                                                      i
 then pos : append(pos, [[i, i + length(ans ) - 1]]), 
                                           i
if h = f then (if not emptyp(p) then print(ans)
 else (print(res, ":", count), [pos])) else (for i in pos do rep : 
append(rep, makelist(n, n, lmin(i), lmax(i))), 
final : map(lambda([x], if member(x, rep) then l  else "_"), 
                                                x
sublist_indices(l, atom)), return(final)))
(%i3) M:[C,A,T,G,C,A,T,C,A];
(%o3)                     [C, A, T, G, C, A, T, C, A]
(%i4) M;
(%o4)                     [C, A, T, G, C, A, T, C, A]
(%i5) "";
(%o5) 
(%i6) find([C,A,T], M, f);
[C, A, T] : 2 
(%o6)                         [[[1, 3], [5, 7]]]
(%i7) "";
(%o7) 
(%i8) find([C,A,T], M, t);
(%o8)                     [C, A, T, _, C, A, T, _, _]
(%i9) cut(M, 1, 3, s);
(%o9)                     [C, A, T, _, _, _, _, _, _]
(%i10) cut(M, 5, 7, s);
(%o10)                    [_, _, _, _, C, A, T, _, _]
(%i11) cut(M, 8, 10, s);
(%o11)                    [_, _, _, _, _, _, _, C, A]
(%i12) find([C, A, T], M, f);
[C, A, T] : 2 
(%o12)                        [[[1, 3], [5, 7]]]
(%i13) 

Related Help

Help for Member