Subtracting references in perl -


I am trying to reduce the two sets of data that are in very array I have given them the general array shown below I would like to subtract

  @x = (1, 2, 3); @ X2 = (2, 3, 4); My @Delta = Map {my $ diff = $ _; Map {$ $ diff - $ _} @ x2} @ x; To get:  
  1-2 1-3 1-4 2-2 2-3 2-4 > 

etc.

I am currently using this:

  my $ i = 0; My $ j = 0; My $ prot_x_var; My $ lipid_x_var; # The calculation of the row in the file containing the data in this section is $ # The amount of data is the array of data ($ $ Count = 0; $ count = l = $ # data; ++ $ count) {# This is a specific string So the $ protein is not important, but to define the string ($ data [$ count] = ~ m / \ s + $ protein \ s + /) {++ $ i; $ I added $ i to get specific string $ prot_x_var = $ protein_xyz_coords-> gt; [0] - & gt; [$ I] - & gt; {'X'}; # Flips through all the data points # Print "$ prot_x_var \ n"; } # $ POPS and $ POPC are being used only to find a string if ($ data [$ count] = ~ m / \ s + $ POPS \ s + /) ($ data [$ count] = ~ M / \ s + $ POPC \ s + /)) {++ $ j; $ As $ i, but $ lipid_x_var = $ lipid_xyz_coords-> for a different string [1] - & gt; [$ J] - & gt; {'X'}; #sprint "# lipid_x_var \ n" as above; }}  

Now I can call each $ lipid_x_var or $ lipid_xyz_coords-> gt; [1] - & gt; [$ J] - & gt; From {'X'} to each $ prot_x_var or $ protein_xyz_coords-> [0] - & gt; [$ I] - & gt; {'X'} The way the above array did it, I have a previous question, which has tried to help me in any way, but now the idea is to come back due to the size of the data Will happen.

I do not know what to do with your query, I will just answer the question. .

The following is the solution that does not store results in memory.

  my @ x1 = (1, 2, 3); My @ x2 = (2, 3, 4); For my $ x1 (@x1) {my $ x2 (@x2) {print ("$ x1- $ x2 =", $ x1- $ x2, "\ n") for; }}  

or if you want an iterator, use

  algorithms :: loop cue (nested loop); My @ x1 = (1, 2, 3); My @ x2 = (2, 3, 4); My $ Eater = Nested Lops ([\ @ x1, \ @ x2]); While (my ($ x1, $ x2) = $ iter- & gt; ()) {print ("$ x1- $ x2 =", $ x1- $ x2, "\ n"); }  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -