Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^3: Comparing a value to a list of numbers

by syphilis (Bishop)
on Jan 30, 2021 at 00:44 UTC ( #11127668=note: print w/replies, xml ) Need Help??

in reply to Re^2: Comparing a value to a list of numbers
in thread Comparing a value to a list of numbers

Please give an example (in perl code) of hose List::Util can be used to solve the OP's problem
use warnings; use strict; use List::Util 'uniq'; my @given = (1,2,5,6,9,10,41..56); my @check = (3,4,9,11,48,102); my $c = uniq(@given); for(@check) { push(@given, $_); print "$_ is in the list\n" unless $c + 1 == uniq(@given); pop(@given); } __END__ Outputs: 9 is in the list 48 is in the list
List::Util::uniq() utilizes the hash lookup referred to elsewhere in this thread.
Some efficiency is lost in this script because uniq() has to generate the hash every time it is called.
It would be more efficient if the perl code itself created the hash (just once), and then re-used that hash for each number that needs to be checked.

Perhaps anonymous had some other List::Util routine in mind.


Replies are listed 'Best First'.
Re^4: Comparing a value to a list of numbers
by LanX (Cardinal) on Jan 30, 2021 at 20:07 UTC

      Like parroting something obvious in an annoying tone and with no own expertise
      Like you, my SunnyD-radar went off the instant I read that "anonymous" post, especially the gratuitous parting shot "There's no reason to do something over if someone else has already done it".

      Curiously, my original 2015 list of SunnyD annoyances mentions pet theories and home-spun wisdoms ... but not platitudes (a remark or statement that has been used too often to be interesting or thoughtful), cliches (a phrase or opinion that is overused and betrays a lack of original thought), truisms (a statement that is obviously true and says nothing new or interesting) or banalities (so lacking in originality as to be obvious and boring). I'll remedy that oversight shortly.

      Meanwhile, I can't help but notice that the 2020-anony-SunnyD incarnation has modified his style from 2015-classic-SunnyD, shortening his posts, toning down the extravagant typography, stylistic devices, and flowery analogies, and migrating from telltale pet theories/home-spun wisdoms to less specific platitudes/cliches/truisms/banalities ... perhaps in a futile attempt to conceal his identity.

        Like you, my SunnyD-radar went off ... perhaps in a futile attempt to hide his true identity.

        successful troll. you don't want him to go away, do you?

A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11127668]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2021-06-13 11:10 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (54 votes). Check out past polls.