Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: (tye)Re5: regexp searches over array slices

by TheDamian (Vicar)
on Nov 16, 2001 at 01:34 UTC ( [id://125685]=note: print w/replies, xml ) Need Help??


in reply to (tye)Re5: regexp searches over array slices
in thread regexp searches over array slices

...would evaluating a(n uncollapsed) superposition in a Boolean context generate a warning/error or would it cause both branches of the code to be (tentatively) run and the results to be indeterminate until something is done to collapse the (expanding) superposition? ;)

Err...neither.

In a boolean context, a disjunctive superposition evaluates to true if any of its eigenstates is true, whilst a conjunctive superposition evaluates to true only if all of its eigenstates are true.

This could add "logic programming" to Perl's bag of paradigms.

Sssssssssshhhhhhhhhhhh!!!!!!! How the heck am I supposed to sneak these new paradigms in if you keep warning everybody beforehand??? ;-)

But, yes, that's the general idea. It would be rather nice to be able to code an n-ary max subroutine declaratively, like so:

sub max (*@values) { any @values >= all @values }
Especially since that version is vastly more amenable to internal parallelization.

Replies are listed 'Best First'.
Re: Re: (tye)Re5: regexp searches over array slices
by japhy (Canon) on Nov 16, 2001 at 01:46 UTC
    Don't you have those two backwards?
    sub max (*@v) { any(@v) >= all(@v) }
    That sounds more logical to me -- it returns any element of @v such that it is greater than or equal to all elements of @v.

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-25 19:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found