Artifact 898db5315c37ba40178afddecec436b705f4c494e9f9bdb1ccbabba4f2adccb7:
- Executable file
r38/packages/misc/sets.rlg
— part of check-in
[f2fda60abd]
at
2011-09-02 18:13:33
on branch master
— Some historical releases purely for archival purposes
git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/trunk/historical@1375 2bfe0521-f11c-4a00-b80e-6202646ff360 (user: arthurcnorman@users.sourceforge.net, size: 2775) [annotate] [blame] [check-ins using] [more...]
Tue Feb 10 12:28:06 2004 run on Linux %% sets.tst %% Author: F.J.Wright@Maths.QMW.ac.uk %% Date: 20 Feb 1994 %% Test of REDUCE sets package, based on the examples on page 51 of %% the "Maple V Language Reference Manual" %% by Char, Geddes, Gonnet, Leong, Monagan and Watt (Springer, 1991). %% The output (especially of symbolic set expressions) looks better %% using PSL-REDUCE under MS-Windows or X in graphics mode. %% Note that REDUCE supports n-ary symbolic infix operators, %% does not require any special quoting to use an infix operator %% as a prefix operator, and supports member as an infix operator. %% However, REDUCE ALWAYS requires evalb to explicitly evaluate a %% Boolean expression outside of a conditional statement. %% Maple 5.2 does not provide any subset predicates. clear a, b, c, x, y, z; s := {x,y} union {y,z}; s := {x,y,z} % s := {x,y,z} t := union({x,y},{y,z}); t := {x,y,z} % t := {x,y,z} evalb(s = t); true % true evalb(s set_eq t); true % true evalb(member(y, s)); true % true evalb(y member s); true % true evalb(y member {x*y, y*z}); false % false evalb(x*y member {x*y, y*z}); true % true {3,4} union a union {3,7} union b; {3,4,7} union a union b % {3,4,7} union a union b {x,y,z} minus {y,z,w}; {x} % {x} a minus b; a\b % a\b a\b; a\b % a\b minus(a,a); {} % {} {x,y,z} intersect {y,z,w}; {y,z} % {y,z} intersect(a,c,b,a); a intersection b intersection c % a intersection b intersection c %% End of Maple examples. (a union b) intersect c where set_distribution_rule; a intersection c union b intersection c % a intersection c union b intersection c algebraic procedure power_set s; %% Power set of a set as an algebraic list (inefficiently): if s = {} then {{}} else {s} union for each el in s join power_set(s\{el}); power_set power_set{}; {{}} power_set{1}; {{1},{}} power_set{1,2}; {{2},{1,2},{1},{}} power_set{1,2,3}; {{3},{2,3},{2},{1,3},{1,2,3},{1,2},{1},{}} evalb 1; true % true evalb 0; false % false evalb(a = a); true % true evalb(a = b); false % false evalb(2 member {1,2} union {2,3}); true % true evalb({2} member {1,2} union {2,3}); false % false evalb({1,3} subset {1,2} union {2,3}); true % true evalb(a subset a union b); true % true evalb(a subset_eq a union b); true % true evalb(a set_eq a union b); false % false evalb(a\b subset a union c); true % true mkset{1,2,1}; {1,2} % {1,2} end; Time for test: 1 ms