Download MuPAD from SciFace

MuPAD Pro Computing Essentials - Examples 

Example 11.3 - Checking Subsets 

This is a procedure to check is a given set is a subset of another set.

  • subset:=proc(A,B)
       local result, a, b;
    begin
       if testtype(A,Type::Set) and 
          testtype(B,Type::Set) then
          result:=TRUE;
          for a in A do 
             result:= bool(a in B) and result;
          end;
          return(result)
       else
          return(procname(args()))
       end;
    end:
 
  • A := {n $ n=1..100}:
    B := {ithprime(n) $ n=1..100} union A:
    K := {b^n $ n=1..100}:
    L := {a^n $ n=1..50}:
  • subset(A,B)

  • subset(K,L)


  • subset(K intersect L, K)

         

TOP