Sponsored links: Algebra eBooks
 

Related

disjoin

Run Example
(%i1)expr:n;
(%o1)                                  n
(%i2) makelist(''expr, n, 1, 100);
(%o2) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 
59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 
78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 
97, 98, 99, 100]
(%i3) set(a,b);
(%o3)                               {a, b}
(%i4) first([1,2]);
(%o4)                                  1
(%i5) map(first, [[1, 2]]);
(%o5)                                 [1]
(%i6) for n:1 thru 10 do for y:1 thru 10 do (if(y=2*n) then print(y));
2 
4 
6 
8 
10 
(%o6)                                done
(%i7) for n:1 thru 10 do (if(mod(n,2)=0) then print([append([n, nil], [])]));
[[2, nil]] 
[[4, nil]] 
[[6, nil]] 
[[8, nil]] 
[[10, nil]] 
(%o7)                                done
(%i8) listify(disjoin(false, setify(makelist((if(mod(n,2)=0) then n else false), n, 1, 10))));
(%o8)                          [2, 4, 6, 8, 10]
(%i9) map(evenp, [1, 2]);
(%o9)                            [false, true]
(%i10) subset(setify(makelist(''expr, n, 1, 10)), lambda([n], evenp(n)));
(%o10)                         {2, 4, 6, 8, 10}
(%i11) map(reverse, map(lambda([n], 1/2^n), setify(makelist(''expr, n, 1, 10))));
(%o11)            {2, 4, 8, 16, 32, 64, 128, 256, 512, 1024}
(%i12) 
Run Example
expr:n;
(%o1)                                  n
(%i2) makelist(''expr, n, 1, 100);
(%o2) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 
59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 
78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 
97, 98, 99, 100]
(%i3) set(a,b);
(%o3)                               {a, b}
(%i4) first([1,2]);
(%o4)                                  1
(%i5) map(first, [[1, 2]]);
(%o5)                                 [1]
(%i6) for n:1 thru 10 do for y:1 thru 10 do (if(y=2*n) then print(y));
2 
4 
6 
8 
10 
(%o6)                                done
(%i7) for n:1 thru 10 do (if(mod(n,2)=0) then print([append([n], [])]));
[[2]] 
[[4]] 
[[6]] 
[[8]] 
[[10]] 
(%o7)                                done
(%i8) listify(disjoin(false, setify(makelist((if(mod(n,2)=0) then n else false), n, 1, 10))));
(%o8)                          [2, 4, 6, 8, 10]
(%i9) map(evenp, [1, 2]);
(%o9)                            [false, true]
(%i10) subset(setify(makelist(''expr, n, 1, 10)), lambda([n], evenp(n)));
(%o10)                         {2, 4, 6, 8, 10}
(%i11) map(reverse, map(lambda([n], 1/2^n), setify(makelist(''expr, n, 1, 10))));
(%o11)            {2, 4, 8, 16, 32, 64, 128, 256, 512, 1024}
(%i12) 
Run Example
? disjoin;

 -- Function: disjoin (<x>, <a>)
     Returns the set <a> without the member <x>.  If <x> is not a
     member of <a>, return <a> unchanged.

     `disjoin' complains if <a> is not a literal set.

     `disjoin(<x>, <a>)', `delete(<x>, <a>)', and `setdifference(<a>,
     set(<x>))' are all equivalent.  Of these, `disjoin' is generally
     faster than the others.

     Examples:

          (%i1) disjoin (a, {a, b, c, d});
          (%o1)                       {b, c, d}
          (%i2) disjoin (a + b, {5, z, a + b, %pi});
          (%o2)                      {5, %pi, z}
          (%i3) disjoin (a - b, {5, z, a + b, %pi});
          (%o3)                  {5, %pi, b + a, z}


  There are also some inexact matches for `disjoin'.
  Try `?? disjoin' to see them.

(%o1)                                true
(%i2) 

Related Help

Help for Disjoin