| Line | |
|---|
| 1 | /* Copyright Vladimir Prus 2003. Distributed under the Boost */ |
|---|
| 2 | /* Software License, Version 1.0. (See accompanying */ |
|---|
| 3 | /* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ |
|---|
| 4 | |
|---|
| 5 | #include "../native.h" |
|---|
| 6 | |
|---|
| 7 | /* |
|---|
| 8 | local result = ; |
|---|
| 9 | local element ; |
|---|
| 10 | for element in $(B) |
|---|
| 11 | { |
|---|
| 12 | if ! ( $(element) in $(A) ) |
|---|
| 13 | { |
|---|
| 14 | result += $(element) ; |
|---|
| 15 | } |
|---|
| 16 | } |
|---|
| 17 | return $(result) ; |
|---|
| 18 | */ |
|---|
| 19 | LIST *set_difference( PARSE *parse, FRAME *frame ) |
|---|
| 20 | { |
|---|
| 21 | |
|---|
| 22 | LIST* b = lol_get( frame->args, 0 ); |
|---|
| 23 | LIST* a = lol_get( frame->args, 1 ); |
|---|
| 24 | |
|---|
| 25 | LIST* result = 0; |
|---|
| 26 | for(; b; b = b->next) |
|---|
| 27 | { |
|---|
| 28 | if (!list_in(a, b->string)) |
|---|
| 29 | result = list_new(result, b->string); |
|---|
| 30 | } |
|---|
| 31 | return result; |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | void init_set() |
|---|
| 35 | { |
|---|
| 36 | { |
|---|
| 37 | char* args[] = { "B", "*", ":", "A", "*", 0 }; |
|---|
| 38 | declare_native_rule("set", "difference", args, set_difference); |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.