![]() |
|
|
#276 |
|
If I May
"Chris Halsall"
Sep 2002
Barbados
9,767 Posts |
|
|
|
|
|
|
#277 | |
|
Jun 2003
7×167 Posts |
Quote:
Code:
no factor for M51795493 from 2^69 to 2^70 [mfaktc 0.17-Win barrett79_mul32] no factor for M51796097 from 2^69 to 2^70 [mfaktc 0.17-Win barrett79_mul32] no factor for M51796097 from 2^70 to 2^71 [mfaktc 0.17-Win barrett79_mul32] no factor for M51813887 from 2^69 to 2^70 [mfaktc 0.17-Win barrett79_mul32] no factor for M51817247 from 2^69 to 2^70 [mfaktc 0.17-Win barrett79_mul32] no factor for M51827527 from 2^69 to 2^70 [mfaktc 0.17-Win barrett79_mul32] no factor for M51827537 from 2^69 to 2^70 [mfaktc 0.17-Win barrett79_mul32] |
|
|
|
|
|
|
#278 | |
|
Jun 2003
100100100012 Posts |
Quote:
Code:
#! /usr/bin/awk -f
BEGIN {
FS=","
}
/^Factor=[^,]*,[0-9]*,[0-9]*,[0-9]*$/ {
if ( !($2 in from) || from[$2] > $3) from[$2] = $3
if ( !($2 in to) || to[$2] < $4) to[$2] = $4
}
END {
n = asorti(from, expo)
for (i = 1; i <= n; i++) for (j = from[expo[i]]; j < to[expo[i]]; j++) print "factor=" expo[i] "," j "," j+1
}
Unfortunately the prog doesn't quite work. Here's the output: Code:
factor=11,7,8 factor=11,8,9 factor=11,9,10 factor=11,10,11 factor=2,1,2 factor=2,2,3 factor=2,3,4 factor=5,4,5 factor=7,5,6 factor=7,6,7 Code:
#! /usr/bin/awk -f
BEGIN {
FS=","
}
/^Factor=[^,]*,[0-9]*,[0-9]*,[0-9]*$/ {
expo[$2]=$2
if ( !($2 in from) || from[$2] > $3) from[$2] = $3
if ( !($2 in to) || to[$2] < $4) to[$2] = $4
}
END {
n = asort(expo)
for (i = 1; i <= n; i++) for (j = from[expo[i]]; j < to[expo[i]]; j++) print "factor=" expo[i] "," j "," j+1
}
Last fiddled with by Mr. P-1 on 2011-11-15 at 22:27 |
|
|
|
|
|
|
#279 | |
|
If I May
"Chris Halsall"
Sep 2002
Barbados
9,767 Posts |
Quote:
Code:
#!/usr/bin/perl
while (<>) {
$_ =~ /.*M(\d*) from 2\^(\d.)* to 2\^(\d.)/;
$Exp{$1} = $1;
if ($From{$1} > $2 || !defined($From{$1})) { $From{$1} = $2; }
if ($To{$1} < $3 || !defined($To{$1})) { $To{$1} = $3; }
}
foreach $key (keys %Exp) {
print "Factor=${key},${From{$key}},${To{$key}}\n";
}
Code:
Factor=51827527,69,70 Factor=51813887,69,70 Factor=51827537,69,70 Factor=51795493,69,70 Factor=51817247,69,70 Factor=51796097,69,71 |
|
|
|
|
|
|
#280 | |
|
If I May
"Chris Halsall"
Sep 2002
Barbados
9,767 Posts |
Quote:
Perl is a procedural language. Much like C or C++ (or Java et al). And, further, can you tell us all how you get a MySQL database handle in AWK? |
|
|
|
|
|
|
#281 | |||
|
Jun 2003
49116 Posts |
Quote:
Quote:
Code:
$_ =~ /.*M(\d*) from 2\^(\d.)* to 2\^(\d.)/; Quote:
I'm not here arguing that AWK is a better language than perl. I took issue with the assertion by Christenson that "the right tool for this isn't sed, or awk". I think I've shown that it is. Of course, perl is also a fine tool for this task too. Christenson also said "Chalsall's perl script would have been shorter than Mr P-1's awk script." I don't think that's been demonstrated either. It looks to me as though our scripts both have pretty much the same components, except that you had to tell perl to do some things (such as loop on the input lines) that AWK does without being told. But that's only useful if what AWK does without being told is what you want it to do. AWK was designed to be very good a performing a particular task, namely reading records (by default, lines) parsing them into fields (by default white-space delimited), and then manipulating these in various not-too-complicated ways. The closer the actual problem fits this paradigm, the better language choice AWK will be. So I would say that the real difference between AWK and perl is not that one is declarative and one procedural, it's that one is special purpose, while the other is general purpose. |
|||
|
|
|
|
|
#282 | ||
|
If I May
"Chris Halsall"
Sep 2002
Barbados
976710 Posts |
Quote:
Quote:
|
||
|
|
|
|
|
#283 |
|
Aug 2002
Termonfeckin, IE
22×691 Posts |
Boo! You call this a language war. You sissies :) We want a real fight!!
|
|
|
|
|
|
#284 | |
|
If I May
"Chris Halsall"
Sep 2002
Barbados
230478 Posts |
Quote:
"Turn this into that."
Last fiddled with by chalsall on 2011-11-16 at 22:36 |
|
|
|
|
|
|
#285 | |
|
Jun 2003
22218 Posts |
Quote:
Code:
$5 ~ /[0-9]./ Code:
$5 ~ /[0-9]+/ |
|
|
|
|
|
|
#286 |
|
Jun 2003
7×167 Posts |
|
|
|
|
![]() |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A quick question | Pegos | Information & Answers | 6 | 2016-08-11 14:39 |
| Quick TF Question | Dubslow | GPU Computing | 2 | 2011-10-27 04:49 |
| Quick msieve question | alkirah | Msieve | 2 | 2009-12-30 14:00 |
| Quick question about P90 CPU metric | stars10250 | PrimeNet | 9 | 2008-08-31 23:58 |
| Quick p-1 question | Unregistered | Software | 8 | 2006-10-13 23:35 |