Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Exclude Problems

 [1/14] from: learned:talentsinc at: 26-Sep-2001 15:47


I have a block of about 480 elements, and am trying to use the exclude function on them. If I set up a second block of even two elements (i.e. ["SYSTEM" "SERIAL"] and execute the following: foo: exclude block1 block2 I end up with far more than just the elements that have SYSTEM and SERIAL removed from foo. Is there a potential problem with exclude, or am I missing someting basic? --- G. Edw. Learned - [learned--talentsinc--net] (Never apply a Star Trek Solution to a Babylon Five Problem)

 [2/14] from: greggirwin:starband at: 26-Sep-2001 15:54


hi G, I haven't used exclude for anything big, but simple tests work. Maybe it's something specific in your data?
>> exclude [1 2 3 4 5 6 7 8 9 0] [3 5]
== [1 2 4 6 7 8 9 0]
>> exclude ["A" "B" "C" "D" "E" "F" "G"] ["C" "F"]
== ["A" "B" "D" "E" "G"]
>> exclude ["AA" "AB" "AC" "AD" "AE" "AF" "AG"] ["AC" "AF"]
== ["AA" "AB" "AD" "AE" "AG"]
>> exclude ["AA" "AB" "AC" "AD" "AE" "AF" "AG"] ["A" "AF"]
== ["AA" "AB" "AC" "AD" "AE" "AG"] --Gregg

 [3/14] from: learned:talentsinc at: 26-Sep-2001 17:08


I thought that too, which is why I reduced it down to excluding just one item, SYSTEM, and it still took out words like SEAGATE and strings like ---- . Is a puzzlement. --On Wednesday, September 26, 2001 3:54 PM -0600 Gregg Irwin <[greggirwin--starband--net]> wrote:
> hi G, > I haven't used exclude for anything big, but simple tests work. Maybe it's
<<quoted lines omitted: 12>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
--- G. Edw. Learned - [learned--talentsinc--net] (Never apply a Star Trek Solution to a Babylon Five Problem)

 [4/14] from: al:bri:xtra at: 27-Sep-2001 15:15


G. Edw. Learned wrote:
> I have a block of about 480 elements, and am trying to use the exclude
function on them. If I set up a second block of even two elements (i.e. ["SYSTEM" "SERIAL"] and execute the following:
> foo: exclude block1 block2 > > I end up with far more than just the elements that have SYSTEM and SERIAL
removed from foo. Is there a potential problem with exclude, or am I missing someting basic? 'exclude will remove all duplicates. So if: block1: ["A" "A" "A" "A"] all but one of the "A" will be removed from block1. Andrew Martin ICQ: 26227169 http://zen.scripterz.org

 [5/14] from: allenk:powerup:au at: 27-Sep-2001 17:23


----- Original Message ----- From: "G. Edw. Learned" <[learned--talentsinc--net]> To: <[rebol-list--rebol--com]> Sent: Thursday, September 27, 2001 8:08 AM Subject: [REBOL] Re: Exclude Problems
> I thought that too, which is why I reduced it down to excluding just one > item, SYSTEM, and it still took out words like SEAGATE and strings like > "----". Is a puzzlement.
Exclude also cleans up duplicate entries, such as.
>> exclude ["AA" "B" "C" "D" "E" "AA" "F" "G" "AA" "B" "AA" "B"] ["C" "F"]
== ["AA" "B" "D" "E" "G"] Could that explain what you are seeing? Cheers, Allen K

 [6/14] from: learned:talentsinc at: 27-Sep-2001 9:12


Argh, I just tested and yes, that's it exactly. I didn't see that little feature documented in the dictionary at the REBOL site. Thanks. Is there a better source of documentation that I should get other than the online word dictionary? On the bad side, it just made exclude totally useless for my project. I don't suppose that remove duplicate is an optional feature? Guess I'm back to remove. --On Thursday, September 27, 2001 5:23 PM +1000 Allen Kamp <[allenk--powerup--com--au]> wrote:
> ----- Original Message ----- > From: "G. Edw. Learned" <[learned--talentsinc--net]>
<<quoted lines omitted: 14>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
--- G. Edw. Learned - [learned--talentsinc--net] (Never apply a Star Trek Solution to a Babylon Five Problem)

 [7/14] from: ammoncooke:yah:oo at: 27-Sep-2001 13:25


Here: excl-only: func [ "This is the Exclude function that doesn't exclude duplicates" block1 "The original block" block2 "The block to be 'excluded'" ][ tmp-block: [none] tmp-block: remove find copy block1 copy block2 either not none? tmp-block[ return head tmp-block ][ return tmp-block ] ] HTH! Ammon ----- Original Message ----- From: "G. Edw. Learned" <[learned--talentsinc--net]> To: <[rebol-list--rebol--com]> Sent: Thursday, September 27, 2001 7:12 AM Subject: [REBOL] Re: Exclude Problems
> Argh, I just tested and yes, that's it exactly. I didn't see that little > "feature" documented in the dictionary at the REBOL site. Thanks. Is there
<<quoted lines omitted: 14>>
> > > >> I thought that too, which is why I reduced it down to excluding just
one
> >> item, SYSTEM, and it still took out words like SEAGATE and strings like > >> "----". Is a puzzlement. > > > > Exclude also cleans up duplicate entries, such as. > >>> exclude ["AA" "B" "C" "D" "E" "AA" "F" "G" "AA" "B" "AA" "B"] ["C"
F ]

 [8/14] from: learned:talentsinc at: 27-Sep-2001 14:45


That seems to work only if block 2 has only one item in it. I need to play with it some more I think. --On Thursday, September 27, 2001 1:25 PM -0700 Ammon Cooke <[ammoncooke--yahoo--com]> wrote:
> Here: > excl-only: func [
<<quoted lines omitted: 74>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
--- G. Edw. Learned - [learned--talentsinc--net] (Never apply a Star Trek Solution to a Babylon Five Problem)

 [9/14] from: ammoncooke::yahoo at: 28-Sep-2001 5:50


Oh, I didn't catch that. Here's the fixed code! excl-only: func [ "This is the Exclude function that doesn't exclude duplicates" block1 "The original block" block2 "The block to be 'excluded'" ][ tmp-block: copy block1 either (length? b) > 1[ repeat val block2 [remove find tmp-block val] ][ remove find tmp-block block2 ] either not none? tmp-block[ return head tmp-block ][ return tmp-block ] ] Enjoy!! Ammon

 [10/14] from: ammoncooke::yahoo at: 28-Sep-2001 5:53


Sorry, I forgot to fully omptimize that code here is a lot smaller version: excl-only: func [ "This is the Exclude function that doesn't exclude duplicates" block1 "The original block" block2 "The block to be 'excluded'" ][ tmp-block: copy block1 repeat val block2 [remove find tmp-block val] either not none? tmp-block[ return head tmp-block ][ return tmp-block ] ] Enjoy!! Ammon

 [11/14] from: joel:neely:fedex at: 28-Sep-2001 1:52


Hi, Ammon, and all, I've been way busy with a pending s/w release, so haven't been keeping up with this thread very well, but... Ammon Cooke wrote:
> Sorry, I forgot to fully omptimize that code here is a lot > smaller version:
<<quoted lines omitted: 11>>
> ] > ]
I'd suggest making TMP-BLOCK a /LOCAL to prevent contaminating the global namespace. I'm not clear on why the following wouldn't be a valid solution. Am I missing some subtlety? remove-all: func [source [block!] targets [block!] /local result] [ result: copy source foreach target targets [ remove find result target ] result ]
>> remove-all [1 2 3 4 5 6 7 8 9] [2 4 6 8]
== [1 3 5 7 9]
>> remove-all [9 8 7 6 5 4 3 2 1] [2 4 6 8]
== [9 7 5 3 1]
>> remove-all [1 9 2 8 3 7 4 5 6] [0 2 4 6 8]
== [1 9 3 7 5]
>> remove-all [1 9 2 8 3 7 4 5 6] []
== [1 9 2 8 3 7 4 5 6]
>> remove-all [1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6] [1 2 3 4 5 6 7 8 9]
== [2 3 3 4 4 4 5 5 5 5 6 6 6 6 6]
>> remove-all [] [1]
== []
>> remove-all [2] [1]
== [2]
>> remove-all [2] []
== [2]
>> remove-all [2] [2 2 2 2]
== []
>> remove-all [1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6] [9 8 7 6 5 4 3 2 1]
== [2 3 3 4 4 4 5 5 5 5 6 6 6 6 6] I can't think of any more obvious test scenarios at the moment, but would be happy to hear of anything I've overlooked. -jn- -- That so few now dare to be eccentric marks the chief danger of the time. -- John Stuart Mill (1806-1873) FIX&PUNCTUATION&joel&dot&neely&at&fedex&dot&com

 [12/14] from: ammoncooke::yahoo at: 28-Sep-2001 8:58


----- Original Message ----- From: "Joel Neely" <[joel--neely--fedex--com]> To: <[rebol-list--rebol--com]> Sent: Thursday, September 27, 2001 11:52 PM Subject: [REBOL] Re: Exclude Problems
<snip> > > I'd suggest making TMP-BLOCK a /LOCAL to prevent contaminating > the global namespace. >
I like that one! I just overlooked it.
> I'm not clear on why the following wouldn't be a valid solution. > Am I missing some subtlety?
<<quoted lines omitted: 5>>
> result > ]
No, that works great! As you can see you still have many years experience on me. ;) I still just starting to crack out of my shell! I wasn't the one asking for it so I am certain that it will do, Bu tI believe it will. \Thanks!! Ammon

 [13/14] from: learned:talentsinc at: 28-Sep-2001 10:05


Thanks, I need to study this code a bit...when things relate to a real world situation it's a lot easier for me to grok. I do have a question though...in theory, this could be done by redefining exclude as well by adding an exclude/only modifier...am I right? Not asking for it, just trying to understand all the options. Thanks again! --On Friday, September 28, 2001 5:50 AM -0700 Ammon Cooke <[ammoncooke--yahoo--com]> wrote:
> Oh, I didn't catch that. Here's the fixed code! > excl-only: func [
<<quoted lines omitted: 127>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
--- G. Edw. Learned - [learned--talentsinc--net] (Never apply a Star Trek Solution to a Babylon Five Problem)

 [14/14] from: ammoncooke::yahoo at: 28-Sep-2001 17:49


Yes you can also redefine 'exclude. There are NO words that you cannot redefine! 'exclude is a native value so its source is not readily available. To define a refinement: some-func: func [/refinement values-to-pass-with-refinement][ if refinement [do code] ] HTH! Ammon PS Did you see the code Joel Neely provided? It is far better than the code I posted.

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted