Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by Anonymous Monk
on Jan 29, 2021 at 19:49 UTC ( #11127659=note: print w/replies, xml ) Need Help??


in reply to Re: 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. Otherwise your "help" is just a waste of space and a waste of everybody's time.
  • Comment on Re^2: Comparing a value to a list of numbers

Replies are listed 'Best First'.
Re^3: Comparing a value to a list of numbers
by syphilis (Bishop) on Jan 30, 2021 at 00:44 UTC
    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.

    Cheers,
    Rob

        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.

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2021-06-13 01:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (54 votes). Check out past polls.

    Notices?