matrix invert routine
Randal Schwartz
merlyn at iwarp.intel.com
Sat Nov 11 06:53:50 AEST 1989
In article <1612 at xn.LL.MIT.EDU>, rkc at XN (rkc) writes:
| I have "spreadsheet-like" data that looks like this:
| a1 b1 c1
| a2 b2 c2
| a3 b3 c3
| and I want to get it in a form like:
| a1 a2 a3
| b1 b2 b3
| c1 c2 c3
| Before I re-invent the wheel, does anyone have anything that will do this? Is
| there perhaps a unix tool that does this sort of thing?
Perl, anyone? (Eeekkk... it's the Perl monster!)
#!/usr/bin/perl
while (<>) {
@F = split;
$fn = 0;
for $f (@F) {
$final{++$fn} .= "$f ";
}
$maxfn = $fn if $maxfn < $fn;
}
for ($fn = 1; $fn <= $maxfn; $fn++) {
($_ = $final{$fn}) =~ s/ $//;
print "$_\n";
}
There, not quite one line, but it'll do. :-)
Just another Perl hacker,
--
/== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\
| on contract to Intel's iWarp project, Hillsboro, Oregon, USA, Sol III |
| merlyn at iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn |
\== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/
More information about the Comp.unix.questions
mailing list