Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Quantum tuples

by spx2 (Deacon)
on Mar 02, 2010 at 04:50 UTC ( [id://826074]=perlmeditation: print w/replies, xml ) Need Help??

There is a module called Quantum::Superpositions , among other things it also allows binary functions to receive quantum parameters. We can extend that to an arbitrary number of parameters. This can serve as a replacement for Algorithm::Loops. Basically you pack up the arguments in a structure like:

[a1,[a2,[a3,...[an,an1]]]..]

the nice property is that each time you look at a ai you get a different value :) In fact, the only thing that concerns you as a programmer , is that you will get every possible combination of the parameters once and only once.

use strict; use warnings; # 18-01-2010 # cartesian product for 3 or more sets using Quantum::Superpositions # works because BINARY in Q::S allows to make quantized functions like + U and p. sub p { return \@_; } sub U { my $i = $_[1]; my @element; # an element of the cartesian product if(ref($i) eq 'ARRAY') { while(1){ push @element,$i->[0]; $i=$i->[1]; last unless ref($i) eq 'ARRAY'; } }; @element=($_[0],@element,$i); print join(' ',@element)."\n" if ref($_[1]) eq 'ARRAY'; } use Quantum::Superpositions BINARY => ['main::U','main::p']; #U(any(1..2),p(any(9..13),p(any(0..1),p(any(2..4),any(5..8))))); U(any(1..2),p(any(2..4),any(5..10)));

Replies are listed 'Best First'.
Re: Quantum tuples
by Anonymous Monk on Mar 02, 2010 at 09:13 UTC
    the nice property is that each time you look at a ai you get a different value :)

    I don't understand why that is a desirable property

      Try to pet schroedingers cat. ;-)

      Quantum computing / algorithms are based on the assumption that a variable can simultaneously be in N states at once. Until you inspect the variable, you do not know what state it is in. This has some major implications on fields like cryptography (every possible 8 byte value could be stored in an 8 "byte" quantum value), shortest path calculations, and other NP Complete type problems if this moves from the realm of theory into practicality.

      There are also theories that you can "entangle" a pair of quantum things (don't remember the word here), separate them by long distances, and use them for instant communication.

      This is a very interesting field, and seeing where this goes over time, in my opinion, is very exciting. OTOH, I am (or was in college) a theory geek.

      It is said that "only perl can parse Perl." I don't even come close until my 3rd cup of coffee. --MidLifeXis

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://826074]
Approved by almut
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found