Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Use SQL

by herveus (Prior)
on Sep 04, 2009 at 10:56 UTC ( [id://793435]=note: print w/replies, xml ) Need Help??


in reply to Combinatorics problem

Howdy!

Put the lists into separate tables. Generate the cross join of the whole set of tables. *poof*

yours,
Michael

Replies are listed 'Best First'.
Re: Use SQL
by vitoco (Hermit) on Sep 04, 2009 at 13:55 UTC

    Using SQL, you can't be sure that the resulting list will preserve the order of the original lists.

    Unsorted original lists and the use of primary keys or clustered tables, the query optimizer, size of lists and blocking factor among others are things I can recall that might change the way the output is returned... :-(

      Howdy!

      Actually, you can ensure the order of the output, but it requires that the base tables include a column with a sort key. Then you have something you can use in an order by clause.

      Fundamentally, generating the cartesian product of the input lists will generate the elements of the output list. Controlling the sequence is a minor additional task.

      yours,
      Michael

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-29 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found