in reply to Re: (Golf) Dependency List Prioritization
in thread (Golf) Dependency List Prioritization

Maybe a little more verbosity would help.

To speak in terms of Perl, if you have a module Foo which requires module Bar to operate, then there is a dependency. Bar must be installed before Foo. In some cases, such as with RPM, you just can't install Foo until Bar is in place. With Perl, you can install Foo, but it will fail, as it is missing its beloved Bar, and your program won't run.

Maybe Foo also needs the module Baz to run, so that is a second dependency. If you also had a Foo::Bar module, which needed Foo, then you have a second dependency. Perhaps Bar also needs something, say, Fubar, to do its thing.

This leads to a dependency structure that looks like this:
my %dep = ( 'Foo' => [ 'Bar','Baz' ], 'Foo::Bar' => [ 'Foo' ], 'Bar' => [ 'Fubar' ], );
Now the idea is to, based on this specification, figure out what order they can be installed in such that each module is only installed when all of its dependencies are satisfied. One such order is:
'Fubar','Bar','Baz','Foo','Foo::Bar'
If you install them in this order, there should be no problems. An invalid ordering would be something like:
'Fubar','Foo','Bar','Baz','Foo::Bar'
In this case Foo does not have either Bar or Baz available, so it can't work. Foo must come after both Bar and Baz.

To answer a question, the order of the dependencies is not relevant. If Foo requires Bar and Baz, you can list Bar and Baz in any order. After all, they just have to be present and accounted for. Apart from that, nothing else matters. This means that the following are equivalent:
'a' => [ 'b','c' ] 'a' => [ 'c','b' ]
These both specify that 'a' requires 'b' and 'c'. It's like saying that a 'car' needs 'gas' and 'tires' to run. As long as you have both, you're good to go. Procedure is irrelevant, as you're not going anywhere until both are present anyway.

What's interesting about this problem is that at first, it seems quite difficult to solve, but with a bit of creative thinking it was really straightforward. It seems to be a matter of perspective.