Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Pseudocode for table data

by BillKSmith (Monsignor)
on Mar 18, 2020 at 22:36 UTC ( [id://11114446]=note: print w/replies, xml ) Need Help??


in reply to Pseudocode for table data

I am not sure what you mean by 'pseudocode'. I often start a small project such as this by writing a Perl program that is valid, but lacks important details. Here is a sample.
use strict; use warnings; sub mean {...} my @genes = ( #'GeneName E1 E2 E3 E4', 'ATA1 12 44 45 33', 'OSA2 100 79 85 83', 'DUA5 66 65 64 67', 'AXANT 4 4 6 2', ); foreach (@genes) { my ($name, @values) = split; print $name, mean(@values); }

It needs an implementation of the 'mean' function. It uses a hard coded array of strings rather than input. The output is unformatted. The default arguments of 'split' may not work as intended. Clearly, the highest priority is the function. I am not ashamed to use a module to do the heavy work.

use List::Util qw(sum); ... sub mean { return sum(@_)/@_ }

Now you should have a working program. Add input and output details until it meets your requirements. As a final step, you may want to replace the module with your own sum function.

Bill

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-26 00:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found