Last change
on this file since 32 was
29,
checked in by landauf, 17 years ago
|
updated boost from 1_33_1 to 1_34_1
|
File size:
1.2 KB
|
Line | |
---|
1 | # Copyright 2001, 2002 Dave Abrahams |
---|
2 | # Copyright 2003 Vladimir Prus |
---|
3 | # Distributed under the Boost Software License, Version 1.0. |
---|
4 | # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) |
---|
5 | |
---|
6 | # difference |
---|
7 | # returns the elements of B that are not in A |
---|
8 | rule difference ( B * : A * ) |
---|
9 | { |
---|
10 | local result = ; |
---|
11 | local element ; |
---|
12 | for element in $(B) |
---|
13 | { |
---|
14 | if ! ( $(element) in $(A) ) |
---|
15 | { |
---|
16 | result += $(element) ; |
---|
17 | } |
---|
18 | } |
---|
19 | return $(result) ; |
---|
20 | } |
---|
21 | |
---|
22 | NATIVE_RULE set : difference ; |
---|
23 | |
---|
24 | # intersection set1 : set2 |
---|
25 | # |
---|
26 | # Removes from set1 any items which don't appear in set2 and returns the result. |
---|
27 | rule intersection ( set1 * : set2 * ) |
---|
28 | { |
---|
29 | local result ; |
---|
30 | for local v in $(set1) |
---|
31 | { |
---|
32 | if $(v) in $(set2) |
---|
33 | { |
---|
34 | result += $(v) ; |
---|
35 | } |
---|
36 | } |
---|
37 | return $(result) ; |
---|
38 | } |
---|
39 | |
---|
40 | rule equal ( set1 * : set2 * ) |
---|
41 | { |
---|
42 | if $(set1) in $(set2) && ( $(set2) in $(set1) ) |
---|
43 | { |
---|
44 | return true ; |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | rule __test__ ( ) |
---|
49 | { |
---|
50 | import assert ; |
---|
51 | |
---|
52 | assert.result 0 1 4 6 8 9 |
---|
53 | : difference 0 1 2 3 4 5 6 7 8 9 : 2 3 5 7 ; |
---|
54 | |
---|
55 | assert.result 2 5 7 : intersection 0 1 2 4 5 6 7 8 9 : 2 3 5 7 ; |
---|
56 | |
---|
57 | assert.true equal 1 1 2 3 : 3 2 2 1 ; |
---|
58 | |
---|
59 | assert.false equal 2 3 : 3 2 2 1 ; |
---|
60 | } |
---|
61 | |
---|
62 | |
---|
Note: See
TracBrowser
for help on using the repository browser.