SET Operations in Perl

G

George

Hi,
how can we do SET Operations in perl using two hashes or arrays
in case it is too easy , please redirect me to some link
thanks
 
A

A. Sinan Unur

what was that you could not understand,
dude

Well, you used SET, suggesting it might be an acronym or something. Since
you do not give an indication of what SET means to you, I am going to
assume that the following FAQ is related to your question:

perldoc -q intersection

As always, I'll remind you that you are supposed to browse through the
complete FAQ list before posting here. If the answer in the FAQ does not
answer your question, please feel free to post a message that contains a
comprehensible description of your question. Before doing so, however, I
sincerely recommend to you to please read the posting guidelines for this
group.

Sinan
 
C

Chris Mattern

George said:
what was that you could not understand,
dude

He can't understand why you think he's telepathic. Not enough
information to have any idea what you're talking about.

Dude.

--
Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
 
G

George

A. Sinan Unur said:
Well, you used SET, suggesting it might be an acronym or something.
Since you do not give an indication of what SET means to you, I am
going to assume that the following FAQ is related to your question:

perldoc -q intersection

As always, I'll remind you that you are supposed to browse through
the complete FAQ list before posting here. If the answer in the FAQ
does not answer your question, please feel free to post a message
that contains a comprehensible description of your question. Before
doing so, however, I sincerely recommend to you to please read the
posting guidelines for this group.

Sinan
Thanks and Sorry I should have looked harder my mistake
 
L

Lambik

Tore said:

Let's start a Poll. I think he want to change an environment variable:

Found in D:\perl5.8\lib\pod\perlfaq8.pod
I {changed directory, modified my environment} in a perl script. How
come the change disappeared when I exited the script? How do I get my
changes to be visible?
Unix
In the strictest sense, it can't be done--the script
executes as a different process from the shell it was
started from. Changes to a process are not reflected in
its parent--only in any children created after the
change. There is shell magic that may allow you to fake
it by eval()ing the script's output in your shell; check
out the comp.unix.questions FAQ for details.
 
B

Brian McCauley

Gregory said:

Those are good if you have sets in arrays.

But if you have to store sets in Perl then arrays are not the natural type.

The natural type in Perl is the valueless hash (i.e. one with only keys).

Some what one usually thinks of as the primative set operations are not
primative in this implementation but the primatives you do have are
sufficient.

The primatives you get are:

Add a list of elements to set:

@set{'element1','emement2'} = ();

Remove a list of elements from set:

delete @set{'element1','emement2'};

Enumerate elements of set:

my @elements = keys %set;

Test if one element is in a set:

exists $set{$element};

Reduce a list to those elements in a set (also test if ant of a list is
in the set in a scalar context):

grep { exists $set{$_} } LIST;

(Note for large data there is an unpleasant overhead for using grep in a
scalar context so for large data don't - roll your own loop).

Union is not as often wanted as you may think - most of the time people
think they want union they can really make do with "add a list elements
to a set".

my %union = ( %set1, %set2 );

Intersection is non-primative but is not as often wanted as you may
think - most of the time people think they want intersection they can
really make do with "reduce a list to those elements in a set".

my %intersection;
@intersection{ grep { exists $set1{$_} keys %set2 }} = ();
 
G

George

Abigail said:
Tintin ([email protected]) wrote on MMMMCLXXXVIII September
MCMXCIII in <url: }}
}} }} > Hi,
}} > how can we do SET Operations in perl using two hashes or arrays
}} > in case it is too easy , please redirect me to some link
}}
}} http://www.set.or.th/th/index.html
}}
}} Can't see the relevance of the Stock Exchange of Thailand (SET)
to hashes }} though.


I think it was a typo. George probably mean SETI Operations.

I know all about them, but I'm not allowed to talk about them.


Abigail

If you don't understand difference between SET Operations and SETI's
Operation , you are sure dumb head, and if someone asks for SETI in
Science group dick head like you will again complain about typo "he
mean SET"
 
G

George

Tintin said:
The point was (as you will no doubt be aware now from other replies),
is that if you are going to ask such a vague open ended question, you
aren't going to get very helpful answers.

The quality of the answers is generally in direct proportion to the
quality of the question.

then how come tore ,gtoomey,sinen understood,
correction to your quote

"The quality of the answers is generally in direct proportion to the
intelligence in person reading question"
 
T

Tintin

George said:
If you don't understand ask,
why would anybody post for stock exchange in perl newsgroup
only stupid imbecile spam head like could relate to that,

The point was (as you will no doubt be aware now from other replies), is
that if you are going to ask such a vague open ended question, you aren't
going to get very helpful answers.

The quality of the answers is generally in direct proportion to the quality
of the question.
 
J

Jonathan Stowe

George said:
If you don't understand difference between SET Operations and SETI's
Operation , you are sure dumb head, and if someone asks for SETI in
Science group dick head like you will again complain about typo "he
mean SET"

I'm so glad to see the quality of new contributors to this newsgroup
hasn't changed over the years.

/J\
 
P

phaylon

George said:
If you don't understand difference between SET Operations and SETI's
Operation , you are sure dumb head, and if someone asks for SETI in
Science group dick head like you will again complain about typo "he mean
SET"

I need a newsreader with Scores lower than -9999 for this kind of posts..
 
P

phaylon

George said:
"The quality of the answers is generally in direct proportion to the
intelligence in person reading question"

Yep. If you don't read, it's at zero. Did you read and think about your
question again after you typed it?
 
D

Daniel Berger

George said:
Hi,
how can we do SET Operations in perl using two hashes or arrays
in case it is too easy , please redirect me to some link
thanks

George,

One option is Set::Array or Set::Hash, available on CPAN.

Regards,

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,169
Messages
2,570,918
Members
47,458
Latest member
Chris#

Latest Threads

Top