[33135] in Perl-Users-Digest
Perl-Users Digest, Issue: 4413 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 13 11:09:21 2015
Date: Mon, 13 Apr 2015 08:09:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 13 Apr 2015 Volume: 11 Number: 4413
Today's topics:
Re: "Deep Recursion" warning on factorial script. <jblack@nospam.com>
Re: "Deep Recursion" warning on factorial script. <rweikusat@mobileactivedefense.com>
Re: "Deep Recursion" warning on factorial script. <rweikusat@mobileactivedefense.com>
Re: "Deep Recursion" warning on factorial script. <bauhaus@futureapps.invalid>
Re: "Deep Recursion" warning on factorial script. <bauhaus@futureapps.invalid>
Re: "Deep Recursion" warning on factorial script. <rweikusat@mobileactivedefense.com>
Re: "Deep Recursion" warning on factorial script. <bauhaus@futureapps.invalid>
Re: "Deep Recursion" warning on factorial script. <lionslair@consolidated.net>
Re: "Deep Recursion" warning on factorial script. <gravitalsun@hotmail.foo>
Re: "Deep Recursion" warning on factorial script. <rweikusat@mobileactivedefense.com>
Re: "Deep Recursion" warning on factorial script. <jblack@nospam.com>
Re: "Deep Recursion" warning on factorial script. <rweikusat@mobileactivedefense.com>
Fun With Unicode <see.my.sig@for.my.address>
Re: Mentifex Strong AI Perlmind Programming Journal: 20 <gravitalsun@hotmail.foo>
Re: Mentifex Strong AI Perlmind Programming Journal: 20 mentificium@gmail.com
Re: One more reason I like Perl. <see.my.sig@for.my.address>
Re: Regex replace line breaks <whynot@pozharski.name>
Re: Regex replace line breaks <see.my.sig@for.my.address>
Re: running Perl scripts w/o extension on Windows 7 <Daniel.A.Mercer@wellsfargo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 11 Apr 2015 23:21:25 -0500
From: John Black <jblack@nospam.com>
Subject: Re: "Deep Recursion" warning on factorial script.
Message-Id: <MPG.2f93aec035031573989823@news.eternal-september.org>
In article <Qj0Ww.255068$bk5.103789@fx06.iad>, lionslair@consolidated.net says...
> I wrote some code that was impossible to copy into assembly. It was to
> tight and efficient. I was able to do assembly in larger memory due to
> the restrictive rules of the compiler.
>
> My machine code was kept to under 4k instructions. Above that I used
> assembly as it was on a larger machine
I probably shouldn't argue since we're getting off topic, but assembly code and machine code
are the same thing. Assembly can use op code names like "ld" instead of numbers and can uses
labels instead of numeric addresses or offsets but there is a 1:1 correspondence between
assembly instructions and machine code instructions.
John Black
------------------------------
Date: Sun, 12 Apr 2015 19:52:48 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: "Deep Recursion" warning on factorial script.
Message-Id: <87k2xhmb5r.fsf@doppelsaurus.mobileactivedefense.com>
John Black <jblack@nospam.com> writes:
> In article <mg41bh$t9u$1@news.grnet.gr>, gravitalsun@hotmail.foo says...
>> On 8/4/2015 4:08 pµ, Robbie Hatley wrote:
>> >
>> > I cooked-up and ran the following script today and it worked fine,
>>
>> make a favor to you computer and yourself and never use recursion when
>> you can do it with a flat iterator like a for
[...]
> I'm curious myself, how deep would you feel comfortable going with in
> recursion? Hundreds obviously. Thousands? More?
>
> In my programming, the most natural uses I've found for recursion was
> when traversing a hierarchy (in VHDL for example). Like any language,
> a top level calls modules, which call other modules and so on.
> Recursion is a natural way to walk the hierarchy. But I was never
> worried about blowing through the stack because while there is no real
> limit on how deep the hierarchy could go, no actual design would go
> deeper than a dozen or so levels.
I don't think 'how deep' is a useful question to ask as the (IMHO) only
sensible answer is "for as far as the stack will carry me PROVIDED
recursion is a good way of expressing the problem". "Mathematicians do
it with functions" aka "Dog licking its balls because it can" is not a
sensible design guideline. Eg, the sum of all integers from 0 .. n can
be expressed recursively as
----
sub up_to_r
{
return $_[0] ? up_to($_[0] - 1) + $_[0] : 0;
}
----
but that's nothing but hand-waiving in order to make the simple appear
sophisticated and the sensible implementation is
----
sub up_to
{
return $_[0] * ($_[0] + 1) / 2;
}
----
Recursion is usually sensible if something like 'a stack of states'
would need to be maintained manually otherwise --- the computer already
knows how to maintain this stack, hence, no explicit code has to be
written for that.
------------------------------
Date: Sun, 12 Apr 2015 21:03:10 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: "Deep Recursion" warning on factorial script.
Message-Id: <87fv85m7wh.fsf@doppelsaurus.mobileactivedefense.com>
Rainer Weikusat <rweikusat@mobileactivedefense.com> writes:
[...]
> Eg, the sum of all integers from 0 .. n can be expressed recursively
> as
>
> ----
> sub up_to_r
> {
> return $_[0] ? up_to($_[0] - 1) + $_[0] : 0;
> }
> ----
>
> but that's nothing but hand-waiving in order to make the simple appear
> sophisticated
Can't resist posting this, too. The example I originally thought of was
this 'elegant' method to add two integers >= 0:
-------
sub add
{
my ($m, $n) = @_;
return ($n || $m) && (1 + !(!$n || !$m) + add($m-- && $m, $n-- && $n)) || 0;
}
------------------------------
Date: Sun, 12 Apr 2015 22:36:17 +0200
From: Georg Bauhaus <bauhaus@futureapps.invalid>
Subject: Re: "Deep Recursion" warning on factorial script.
Message-Id: <mgeku8$fvo$1@dont-email.me>
On 12.04.15 22:03, Rainer Weikusat wrote:
> sub add
> {
> my ($m, $n) = @_;
> return ($n || $m) && (1 + !(!$n || !$m) + add($m-- && $m, $n-- && $n)) || 0;
> }
>
This triggers a question again to which I haven't found a satisfactory answer:
Does Perl guarantee some sequencing of '--' in arguments of '+', so that
!$n is evaluated before $n-- has had an effect?
------------------------------
Date: Sun, 12 Apr 2015 23:02:57 +0200
From: Georg Bauhaus <bauhaus@futureapps.invalid>
Subject: Re: "Deep Recursion" warning on factorial script.
Message-Id: <mgemg7$lnj$1@dont-email.me>
On 11.04.15 15:54, gamo wrote:
> i = i + 1
A long time ago, I was staring at this. The i was an a in my case,
or, more likely, an A.
At the time I knew no one who could tell me how this could possibly work,
and as the "literature" accompanying the thing was only trying to
explain, yet used all those scientific words, I felt stupid.
That feeling only vanished after the first proper introduction.
The HP desk calculators' stack OTOH, seemed totally intuitive.
(Since then, I have developed a preference for good introductions,
and a dislike of too much overload in punctuation.)
Glad to hear that the word "impossible" is a justifiable interpretation
of the above. 8-)
------------------------------
Date: Sun, 12 Apr 2015 22:20:16 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: "Deep Recursion" warning on factorial script.
Message-Id: <87bnitm4bz.fsf@doppelsaurus.mobileactivedefense.com>
Georg Bauhaus <bauhaus@futureapps.invalid> writes:
> On 11.04.15 15:54, gamo wrote:
>> i = i + 1
[...]
> Glad to hear that the word "impossible" is a justifiable interpretation
> of the above. 8-)
The = which exists in languages using = as assignment operator and the =
which exists in languages using it to assert or test for equivalence are
false cognates, just like bekommen (::= to get) and to become (::= zu
etwas werden) are in German and English. Nevertheless, claiming that the
English invented impossible German or the Germans impossible English
just because "Bekommen wir bald etwas zu Essen?" cannot be transformed
to "Will we become food soon?" without changing the meaning makes
little sense: The languages are different.
------------------------------
Date: Mon, 13 Apr 2015 01:04:17 +0200
From: Georg Bauhaus <bauhaus@futureapps.invalid>
Subject: Re: "Deep Recursion" warning on factorial script.
Message-Id: <mgetjp$gih$1@dont-email.me>
On 12.04.15 23:20, Rainer Weikusat wrote:
> The languages are different.
Any language is different from any other than itself. But
not every difference is a false friend, let alone of necessity(*).
In any case, the emphasis would be on an introduction to '=':
one needs a chance to learn that the repertoire of symbols takes
on different meanings in different contexts. I find it perfectly
natural to read (A . B) as a conjunction, but that wasn't the case
at school and conjunction isn't the only interpretation. Lisp programmers
probably won't like it. Perl programmers will expect concatenation,
just like SNOBOL-4 programmers. Without an elitist approach, though,
there is no excuse for interpreting everything differently once again,
IMHO.
3 + 4 = -1
"The languages are just different, you know. '+' stands for
subtraction, as we have already used '-' as the negation operator."
__
(*) But it is true that some translators (of movie dialogues, of
business English) produce "impossible" German. And vice versa, I suppose.
"becomes":
http://www.i-programmer.info/history/people/144-dijkstra.html?start=1
------------------------------
Date: Sun, 12 Apr 2015 21:23:23 -0500
From: Martin Eastburn <lionslair@consolidated.net>
Subject: Re: "Deep Recursion" warning on factorial script.
Message-Id: <xMFWw.126830$WX4.26009@fx17.fr7>
John they are not the same thing.
In assembly one uses Text messages:
NOP
JMP addr2
where machine :
000
303 000 323
The assembly is like a low level language. Jumps are to labels...
In machine a jump is to binary 16 bit (in those days) addresses.
Much different. One complies Assembly into machine but fixes the code
with a text editor.
Machine code is keyed in by hand, paper tape or loaded off disk.....
Assembly becomes machine after a compile. It is fixed in text editor
and compiled again until a final binary run program is found to work.
Machine is written in executable code. But on paper first and then
keyed in via switches or pads.
Martin
On 4/11/2015 11:21 PM, John Black wrote:
> In article <Qj0Ww.255068$bk5.103789@fx06.iad>, lionslair@consolidated.net says...
>> I wrote some code that was impossible to copy into assembly. It was to
>> tight and efficient. I was able to do assembly in larger memory due to
>> the restrictive rules of the compiler.
>>
>> My machine code was kept to under 4k instructions. Above that I used
>> assembly as it was on a larger machine
>
> I probably shouldn't argue since we're getting off topic, but assembly code and machine code
> are the same thing. Assembly can use op code names like "ld" instead of numbers and can uses
> labels instead of numeric addresses or offsets but there is a 1:1 correspondence between
> assembly instructions and machine code instructions.
>
> John Black
>
------------------------------
Date: Mon, 13 Apr 2015 11:42:06 +0300
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: "Deep Recursion" warning on factorial script.
Message-Id: <mgfvgt$vgo$2@news.grnet.gr>
On 12/4/2015 11:36 μμ, Georg Bauhaus wrote:
> On 12.04.15 22:03, Rainer Weikusat wrote:
>
>> sub add
>> {
>> my ($m, $n) = @_;
>> return ($n || $m) && (1 + !(!$n || !$m) + add($m-- && $m, $n-- &&
>> $n)) || 0;
>> }
>>
>
> This triggers a question again to which I haven't found a satisfactory
> answer:
> Does Perl guarantee some sequencing of '--' in arguments of '+', so that
> !$n is evaluated before $n-- has had an effect?
>
what have been found/evaluated first from left --> rigth
------------------------------
Date: Mon, 13 Apr 2015 15:15:29 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: "Deep Recursion" warning on factorial script.
Message-Id: <876190867y.fsf@doppelsaurus.mobileactivedefense.com>
Georg Bauhaus <bauhaus@futureapps.invalid> writes:
> On 12.04.15 23:20, Rainer Weikusat wrote:
>> The languages are different.
>
> Any language is different from any other than itself. But
> not every difference is a false friend, let alone of necessity(*).
This is a case were usage diverged in the past despite common roots and
as of today, the historic divergence is a fact of life which has to be
dealt with.
> In any case, the emphasis would be on an introduction to '=':
> one needs a chance to learn that the repertoire of symbols takes
> on different meanings in different contexts. I find it perfectly
> natural to read (A . B) as a conjunction, but that wasn't the case
> at school and conjunction isn't the only interpretation.
> Lisp programmers probably won't like it. Perl programmers will expect
> concatenation, just like SNOBOL-4 programmers.
Unless some context supplies an interpretation, (A . B) doesn't mean
anything. It could be two people in a half-pipe playing with a ball.
> Without an elitist approach, though, there is no excuse for
> interpreting everything differently once again, IMHO.
>
> 3 + 4 = -1
>
> "The languages are just different, you know. '+' stands for
> subtraction, as we have already used '-' as the negation operator."
'Mathematically', + is an operator symbol and it represents some kind of
operation defined on the members of some set. Consequently,
3 + 4 = 0.75
for some definition of +.
Or
("3" + "4").equals("34")
but
("34" - "4")
is an error and not "3".
[...]
> http://www.i-programmer.info/history/people/144-dijkstra.html?start=1
To date, the most horrendous mess I encountered in code had been
written in Python (with the parts of the SEAM2 implementation I have the
mispleasure to be familiar with a close second). And that's IMHO always
going to be the outcome when people are given sets of abstact rules they
must obey to but are free to apply all of their ingenuitiy in order to
continue "writing FORTRAN in any language", IOW, I consider this a very
bad article.
------------------------------
Date: Mon, 13 Apr 2015 09:41:08 -0500
From: John Black <jblack@nospam.com>
Subject: Re: "Deep Recursion" warning on factorial script.
Message-Id: <MPG.2f95916c5730077e989824@news.eternal-september.org>
In article <xMFWw.126830$WX4.26009@fx17.fr7>, lionslair@consolidated.net says...
>
> John they are not the same thing.
>
> In assembly one uses Text messages:
>
> NOP
> JMP addr2
>
> where machine :
> 000
> 303 000 323
>
> The assembly is like a low level language. Jumps are to labels...
> In machine a jump is to binary 16 bit (in those days) addresses.
>
> Much different. One complies Assembly into machine but fixes the code
> with a text editor.
>
> Machine code is keyed in by hand, paper tape or loaded off disk.....
>
> Assembly becomes machine after a compile. It is fixed in text editor
> and compiled again until a final binary run program is found to work.
>
> Machine is written in executable code. But on paper first and then
> keyed in via switches or pads.
>
> Martin
Martin, I am aware of what you say above. I was responding to comments like these:
>> I wrote some code that was impossible to copy into assembly. It was too
>> tight and efficient.
There is no machine code that is "impossible" to code in assemby because it is "too tight and
efficient". Any code that can be written in machine code can be written in assembly more
easily. The assembler changes JMP to 303 which makes things more readable but changes
nothing. The assembler also converts labels to addresses and offsets but that is also a just
matter of conviencence (so you don't have to do it by hand) - again, that changes nothing.
The code will be just as tight and efficient unless the coder just doesn't know what he is
doing.
John Black
> On 4/11/2015 11:21 PM, John Black wrote:
> > In article <Qj0Ww.255068$bk5.103789@fx06.iad>, lionslair@consolidated.net says...
> >> I wrote some code that was impossible to copy into assembly. It was to
> >> tight and efficient. I was able to do assembly in larger memory due to
> >> the restrictive rules of the compiler.
> >>
> >> My machine code was kept to under 4k instructions. Above that I used
> >> assembly as it was on a larger machine
> >
> > I probably shouldn't argue since we're getting off topic, but assembly code and machine code
> > are the same thing. Assembly can use op code names like "ld" instead of numbers and can uses
> > labels instead of numeric addresses or offsets but there is a 1:1 correspondence between
> > assembly instructions and machine code instructions.
> >
> > John Black
> >
------------------------------
Date: Mon, 13 Apr 2015 15:51:41 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: "Deep Recursion" warning on factorial script.
Message-Id: <87wq1g6pz6.fsf@doppelsaurus.mobileactivedefense.com>
John Black <jblack@nospam.com> writes:
> In article <xMFWw.126830$WX4.26009@fx17.fr7>, lionslair@consolidated.net says...
>>
>> John they are not the same thing.
>>
>> In assembly one uses Text messages:
>>
>> NOP
>> JMP addr2
>>
>> where machine :
>> 000
>> 303 000 323
[...]
> Martin, I am aware of what you say above. I was responding to comments like these:
>
>>> I wrote some code that was impossible to copy into assembly. It was too
>>> tight and efficient.
>
> There is no machine code that is "impossible" to code in assemby because it is "too tight and
> efficient". Any code that can be written in machine code can be written in assembly more
> easily.
Mel loved the RPC-4000 because he could optimize his code: that is,
locate instructions on the drum so that just as one finished its job,
the next would be just arriving at the “read head” and available for
immediate execution. There was a program to do that job, an “optimizing
assembler”, but Mel refused to use it.
“You never know where it's going to put things”, he explained,
“so you'd have to use separate constants”.
It was a long time before I understood that remark. Since Mel
knew the numerical value of every operation code, and assigned
his own drum addresses, every instruction he wrote could also be
considered a numerical constant. He could pick up an earlier
“add” instruction, say, and multiply by it, if it had the right
numeric value.
SCNR.
------------------------------
Date: Mon, 13 Apr 2015 03:45:30 -0700
From: Robbie Hatley <see.my.sig@for.my.address>
Subject: Fun With Unicode
Message-Id: <s9GdnXonTOPXA7bInZ2dnUVZ57ydnZ2d@giganews.com>
I had a list of names, with added detritus, which I wanted to clean-up
and collate alphabetically. However, some of these names have some
characters which cannot be expressed in ASCII or ISO-8859-1, and
indeed I found out that the text in question is encoded in UTF-8.
For test purposes, here is a drastically shortened version of the
list:
Ed Gooz Unblock
Emirjon Fishta Unblock
Nathan Gutierrez Unblock
Amanda Alatti Unblock
Yuri Aleksei Carrión Belliard Unblock
Zackry Wallace-Bell Unblock
Collin Tierney Unblock
Frederic Moseley Jr. Unblock
İrfan Qureyş Unblock
Arthur Vullamparthi Unblock
Kate Onthetimeline Unblock
Mary Elizabeth Blackley Unblock
Lisa Lauchstedt Unblock
Padraic O'Driscoll Unblock
Ragu PG Unblock
Tammy Houghtaling Unblock
Sifokl AlSifokli Unblock
Nékoé Mīkûriá Unblock
John Froex Unblock
Chasity Ahmad Unblock
So I wrote a script to clean and collate that list.
But my first few attempts were *NOT* successful, so I had to
work to find solutions for some problems.
Firstly, I discovered that the first line of the original file
started with "Byte Order Mark" or "BOM", which was "\x{EFBBBF}".
My attempts to remove that were failing. But after doing some
research I discovered that the representation of the BOM
inside Perl is *NOT* the same as the bytes in the file. A Unicode
BOM at the beginning of a file is EFBBBF, but the internal
representation in Perl is "\x{FEFF}", or "\N{BOM}" for short.
Then I struggled with pattern matches to end-of-line that weren't
working, before I realized each line had an invisible "\x0d" on
the end of it, because chomp was removing the "\x0a" from "\x0d0a"
and leaving the "\x0d" behind.
Then I struggled with the name "İrfan Qureyş" being sorted to the
end instead of between H and J where it belongs, until I realized
that Perl was sorting by codepoint ordinal instead of alphabetically.
But then I discovered Unicode::Collate.
Having cleared those issues up, my script looks like this:
#! /usr/bin/perl
use v5.14;
use strict;
use warnings;
use open qw( :encoding(utf8) :std );
use Unicode::Collate;
use charnames ":short";
sub process_line (_) {
s/[\x0a\x0d]+$//; # Get rid of newline (Windows OR Unix).
s/^\N{BOM}//; # Get rid of BOM at start of line (if any).
s/\s*(.+)\s+Unblock$/$1/; # Get rid of leading/trailing space & junk.
$_ .= "\x0a"; # Add Unix-style newline.
}
print Unicode::Collate->new->sort( map {process_line} <> );
and the cleaned & sorted version of the name list above looks like this:
Amanda Alatti
Arthur Vullamparthi
Chasity Ahmad
Collin Tierney
Ed Gooz
Emirjon Fishta
Frederic Moseley Jr.
İrfan Qureyş
John Froex
Kate Onthetimeline
Lisa Lauchstedt
Mary Elizabeth Blackley
Nathan Gutierrez
Nékoé Mīkûriá
Padraic O'Driscoll
Ragu PG
Sifokl AlSifokli
Tammy Houghtaling
Yuri Aleksei Carrión Belliard
Zackry Wallace-Bell
Everything is sorted to the right place, even "İrfan Qureyş".
As always, I'm open to better ways of implementing things.
Does anyone see any improvements that could be made to
the above script?
--
Cheers,
Robbie Hatley
Midway City, CA, USA
perl -le 'print "\154o\156e\167o\154f\100w\145ll\56c\157m"'
http://www.well.com/user/lonewolf/
https://www.facebook.com/robbie.hatley
------------------------------
Date: Mon, 13 Apr 2015 11:39:57 +0300
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: Mentifex Strong AI Perlmind Programming Journal: 2015 April 12
Message-Id: <mgfvct$vgo$1@news.grnet.gr>
On 12/4/2015 8:48 μμ, mentificium@gmail.com wrote:
> The Perlmind Programming Journal (PMPJ) is a record
> from the very start of how the Mentifex Strong AI Mind
> project moves beyond REXX and Forth and JavaScript into
> the Perl programming environment.
>
> Mentifex
>
I am interesting at AI.
What you have done so far, do you have a working prototype ;
------------------------------
Date: Mon, 13 Apr 2015 06:02:02 -0700 (PDT)
From: mentificium@gmail.com
Subject: Re: Mentifex Strong AI Perlmind Programming Journal: 2015 April 12
Message-Id: <983e3c52-d8ff-4685-a67a-03650b358d6d@googlegroups.com>
On Monday, April 13, 2015 at 1:40:02 AM UTC-7, George Mpouras wrote:
> On 12/4/2015 8:48 =CE=BC=CE=BC, mentificium@gmail.com wrote:
> > The Perlmind Programming Journal (PMPJ) is a record
> > from the very start of how the Mentifex Strong AI Mind
> > project moves beyond REXX and Forth and JavaScript into
> > the Perl programming environment.
> >
> > Mentifex
> >
>=20
> I am interesting at AI.
> What you have done so far, do you have a working prototype ;
There are working prototypes in Forth and in JavaScript:
http://www.nlg-wiki.org/systems/Mind.Forth in English;=20
http://dl.acm.org/citation.cfm?doid=3D307824.307853
http://www.nlg-wiki.org/systems/Wotan (Win32Forth) in German;=20
http://www.nlg-wiki.org/systems/Mind (JavaScript) in English;=20
http://www.nlg-wiki.org/systems/Dushka (JavaScript) in Russian.=20
The efforts to port AI Minds into Perl have just begun.=20
Best wishes; stay tuned; and thanks for inquiring.
Arthur T. Murray (Mentifex)=20
--=20
http://cyborg.blogspot.com=20
http://ai.neocities.org/mentifex_faq.html=20
http://www.cpan.org/authors/id/M/ME/MENTIFEX/mind.txt=20
http://mind.sourceforge.net/perl.html
------------------------------
Date: Sat, 11 Apr 2015 13:21:30 -0700
From: Robbie Hatley <see.my.sig@for.my.address>
Subject: Re: One more reason I like Perl.
Message-Id: <gpWdnQ0cdOvdH7TInZ2dnUVZ572dnZ2d@giganews.com>
On 4/8/2015 8:41 AM, Rainer Weikusat wrote:
> ...Well, C++ may be nice for throwaway programs even the author only wants
> to run for the odd 5 hours or so (which have to be thrown away after his
> death because nobody will ever be able to figure out what they were
> supposed to do and to which degree they're actually doing this) ...
<OT topics="C, math, programming, comments">
LOL! Reminds me of a C program I wrote around 2000AD called "series.c".
I found this on my hard disk a few days ago. Obviously it's incomplete
(as evidenced by the lines marked "STUB!"); but after 15 years I don't
remember what this program was supposed to do, so finishing it is going
to be problematic. Obviously it tests the convergence of some series,
but *what* series? I wish I had written some comments explaining what
OddProd and EvenProd are. Some kind of iterative products?
/* file "/rhe/src/math/series.c" */
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include <math.h>
double OddProd(double i);
double EvenProd(double i);
int main(int argc, char *argv[])
{
double i=0.0, limit=10.0, v=3.0;
if(argc!=2)
{
printf("Missing argument.\n");
exit(500);
}
limit=(double)atoi(argv[1]);
if ( limit < 1.0 || limit > 100000000.0 )
{
printf("Limit out of bounds.\n");
exit(600);
}
for(i=0;i<=limit;++i)
{
v=v+3.0*OddProd(i)/(EvenProd(i)*(2.0*i+1.0)*pow(2.0,2.0*i+1.0));
printf("i = %6.0f v = %1.8f\n", i, v);
}
return 0;
}
double OddProd(double i)
{
return 1.0 + 0.0*i; /* STUB! */
}
double EvenProd(double i)
{
return 1.0 + 0.0*i; /* STUB! */
}
</OT>
--
Cheers,
Robbie Hatley
Midway City, CA, USA
perl -le 'print "\154o\156e\167o\154f\100w\145ll\56c\157m"'
http://www.well.com/user/lonewolf/
https://www.facebook.com/robbie.hatley
------------------------------
Date: Sun, 12 Apr 2015 10:14:40 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Regex replace line breaks
Message-Id: <slrnmik6r0.d1g.whynot@orphan.zombinet>
with <E_6dnZwKTYbwbrXInZ2dnUVZ572dnZ2d@giganews.com> Robbie Hatley
wrote:
> On 4/8/2015 12:49 AM, Eric Pozharski wrote:
>> Robbie Hatley wrote:
>>> On 4/7/2015 1:20 AM, gamo wrote:
>>>> El 07/04/15 a las 09:25, Robbie Hatley escribió:
*SKIP*
> You erased the "case" in question. The erased text would have answered
> your question for you. Here's what I *actually* wrote:
Guess what? I can unwind threads too. What EBCDIC has to do with this
(<3NKdnfwD5t1XPb3InZ2dnUVZ5sqdnZ2d@giganews.com>)?
I am reading and storing an entire text file into a single
string variable. My goal is to replace all line feed (LF) or
carriage return (CR) characters with a single CR
character.
Basically, I need to ensure that all paragraphs in my
string are single-spaced with a single CR character.
*CUT*
--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
------------------------------
Date: Mon, 13 Apr 2015 04:30:35 -0700
From: Robbie Hatley <see.my.sig@for.my.address>
Subject: Re: Regex replace line breaks
Message-Id: <N-6dnVhqGcxBNbbInZ2dnUVZ572dnZ2d@giganews.com>
On 4/12/2015 12:14 AM, Eric Pozharski wrote:
> Guess what?
What?
> I can unwind threads too.
Makes a mighty big mess on the floor.
> I am reading and storing an entire text file into a single
> string variable. My goal is to replace all line feed (LF) or
> carriage return (CR) characters with a single CR
> character.
>
> Basically, I need to ensure that all paragraphs in my
> string are single-spaced with a single CR character.
So why are you promoting s/\v+/\n/g as a solution to the OP's
stated problem? It's not. It assumes that he actually means
LF (\n) rather than CR (\r). But assumptions are dangerous.
So even if you take the pragmatic approach instead of the
fastidious approach, the solution would be s/\v+/\r/g rather
than s/\v+/\n/g .
But I tend to do people the honor of assuming that they actually
do mean what they said (instead of assuming that I know better),
so my preferred solution would be s/[\x0a\x0d]+/\x0d/g .
Especially seeing as he also specified that on his system:
CR = \r = \x0d
LF = \n = \x0a <===
> What EBCDIC has to do with this?
CR = \r = \x0d
LF = \n = \x25 <===
--
Cheers,
Robbie Hatley
Midway City, CA, USA
perl -le 'print "\154o\156e\167o\154f\100w\145ll\56c\157m"'
http://www.well.com/user/lonewolf/
https://www.facebook.com/robbie.hatley
------------------------------
Date: Mon, 13 Apr 2015 01:59:33 -0500
From: damercer2850 <Daniel.A.Mercer@wellsfargo.com>
Subject: Re: running Perl scripts w/o extension on Windows 7
Message-Id: <KZOdnT8Ic7TI9LbInZ2dnUU7-KednZ2d@giganews.com>
Hard link your perl scripts to versions with a .pl extension:
$ for i in !(*.pl);do ln $i $i.pl;done
Then use the --include and --exclude options when you rsync:
To Windows:
--include '*.pl' --exclude '*'
To Unix/Linux:
--exclude '*.pl'
Dan Mercer
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 4413
***************************************