Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Algorithm for cancelling common factors between two lists of multiplicands

by hv (Parson)
on Aug 08, 2005 at 19:58 UTC ( #482002=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
      sub combine_factors {
        my $list = shift;
    ...
      ($fa->{$_} ||= 0) -= $fb->{$_} for keys %$fb;
      my @c = map +($_) x $fa->{$_}, grep $fa->{$_} > 0, keys %$fa;
      my @d = map +($_) x -$fa->{$_}, grep $fa->{$_} < 0, keys %$fa;
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2019-10-19 22:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?