mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > PrimeNet

Reply
 
Thread Tools
Old 2011-11-17, 05:38   #287
Mr. P-1
 
Mr. P-1's Avatar
 
Jun 2003

7·167 Posts
Default

Quote:
Originally Posted by chalsall View Post
You are correct. Although my script was only 12 lines vs. your 22, mine contained 299 characters while yours contained 302 (with indentation removed from both scripts). Basically, identical.
Mine contained a whole statement:

Code:
                ORS="\r\n"
taken from dublow's original, which as far as I can see is an adaptation to a Windows environment. It's not necessary in *nix. You also used a shorter variable name: "$To" versus "bita".

I could have merged the two tests. Instead of

Code:
$5 in bita      {
                if (bita[$5] > $8) bita[$5] = $8
                if (bitb[$5] < $11) bitb[$5] = $11
                next
                }

$5 ~ /[0-9]+/   {
                bita[$5] = $8
                bitb[$5] = $11
                }
I could have written

Code:
$5 ~ /[0-9]+/   {
                if (! ($5 in bita) || bita[$5] > $8) bita[$5] = $8
                if (! ($5 in bitb) || bitb[$5] < $11) bitb[$5] = $11
                }
Mr. P-1 is offline   Reply With Quote
Old 2011-11-17, 05:49   #288
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
Jun 2011
Thailand

32·29·37 Posts
Default

Quote:
Originally Posted by Mr. P-1 View Post
The ideal computer language has just one statement:

"Do what I want".
That is implemented already. The computers do what you told them to do, and not what you intended to tell them to do. (or what you believe that you told them to do).

Last fiddled with by LaurV on 2011-11-17 at 05:51
LaurV is online now   Reply With Quote
Old 2011-11-17, 06:42   #289
Dubslow
Basketry That Evening!
 
Dubslow's Avatar
 
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

3×29×83 Posts
Default

Indeed, it is for Winblows. I was wondering about the regex, but what it output worked just fine, seeing as the only numbers to be parsed are the ones we need.
Dubslow is offline   Reply With Quote
Old 2011-11-17, 06:47   #290
Christenson
 
Christenson's Avatar
 
Dec 2010
Monticello

179510 Posts
Default

Perhaps it is time I learned awk...but what I would say of perl is:
1) It is a GENERAL tool. I'd argue that unless the user has a lot of work to do that the specific tool is really good at, the general tool is better. This is not the case here; this is a one-off that will soon be forgotten when the task is over.
2) Perl is designed as a conscious attempt to minimise the amount of programming effort for one-off problems.
3) If sed can do it, perl has a "sed" mode.

Now, let's fight!!!
Anyone know what I should look at on the net besides "man awk"?
Christenson is offline   Reply With Quote
Old 2011-11-17, 06:48   #291
Dubslow
Basketry That Evening!
 
Dubslow's Avatar
 
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

3·29·83 Posts
Default

http://www.grymoire.com/Unix/Awk.html is what I used to crap together my not-a-program.
Dubslow is offline   Reply With Quote
Old 2011-11-17, 11:50   #292
Mr. P-1
 
Mr. P-1's Avatar
 
Jun 2003

7×167 Posts
Default

Quote:
Originally Posted by Christenson View Post
Perhaps it is time I learned awk...but what I would say of perl is:
1) It is a GENERAL tool. I'd argue that unless the user has a lot of work to do that the specific tool is really good at, the general tool is better. This is not the case here; this is a one-off that will soon be forgotten when the task is over.
If you have both tools, and are equally adept at using both, then you would naturally choose to tool best suited for the job at hand, regardless of whether you have a lot of similar work or not.

If you only have the general tool, it might be worth acquiring the specific tool if you did have a lot of work that it's really good at. If you only have the specific tool, it might be worth acquiring the general tool if you had even a little work the specific tool was not good at.

Quote:
2) Perl is designed as a conscious attempt to minimise the amount of programming effort for one-off problems.
Indeed. Larry Wall said there was a subset of perl that looks like AWK.

Quote:
3) If sed can do it, perl has a "sed" mode.
I use sed for simple substitutions. I know it can do more than that, but I've never bothered to learn.

Quote:
Anyone know what I should look at on the net besides "man awk"?
dunno. I just use GAWK info.
Mr. P-1 is offline   Reply With Quote
Reply



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

All times are UTC. The time now is 11:17.


Mon Aug 2 11:17:51 UTC 2021 up 10 days, 5:46, 0 users, load averages: 0.97, 1.04, 1.23

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.