equivalent controls
am 29.11.2007 03:25:13 von Wade Ward
use strict;
use warnings;
my $x_calc = 5.3;
my $x_sought = 7.321928094887362;
my $base = .5;
my $term = -.00057;
my $penultimate = -.00057;
my $cows_come_home = 0;
my $power = 1;
#$term = (10.0*(2.0**$x_calc) > 1600.0);
$term = 10.0*(2.0**$x_sought);
print STDOUT " is $term \n";
do {{
$x_calc++;
$power++;
last if $x_calc > 10;
print STDOUT "x calc is $x_calc\n";
print STDOUT "x_calc out is $x_calc\n";
print STDOUT "power out is $power\n";
do {{
$power++;
$x_calc++;
print STDOUT "power in is $power\n";
print STDOUT "x_calc in is $x_calc\n";
$x_sought = $x_sought - 1;
last if 1 > 0;
print STDOUT "x sought is $x_sought\n";
}} until $x_calc > 7.5;
$x_calc = $penultimate;
}} until ($power > 6);
print STDOUT "power is $power\n";
print STDOUT "base is $base\n";
# output prelims
is 1600
x calc is 6.3
x_calc out is 6.3
power out is 2
power in is 3
x_calc in is 7.3
power in is 4
x_calc in is 8.3
x calc is 0.99943
x_calc out is 0.99943
power out is 5
power in is 6
x_calc in is 1.99943
power in is 7
x_calc in is 2.99943
power in is 8
x_calc in is 3.99943
power in is 9
x_calc in is 4.99943
power in is 10
x_calc in is 5.99943
power in is 11
x_calc in is 6.99943
power in is 12
x_calc in is 7.99943
power is 12
base is 0.5
# end output prelims begin comment
I've got this nested do control to show the behavior I'm looking for.
Is there a slicker way to do this in perl than using the double curly
braces?
--
wade ward
wade@zaxfuuq.net
435 -838-7760
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Re: equivalent controls
am 29.11.2007 04:52:37 von jurgenex
Wade Ward wrote:
[...]
> do {{
> $x_calc++;
> $power++;
>
> last if $x_calc > 10;
> print STDOUT "x calc is $x_calc\n";
> print STDOUT "x_calc out is $x_calc\n";
> print STDOUT "power out is $power\n";
> do {{
> $power++;
> $x_calc++;
> print STDOUT "power in is $power\n";
> print STDOUT "x_calc in is $x_calc\n";
> $x_sought = $x_sought - 1;
> last if 1 > 0;
> print STDOUT "x sought is $x_sought\n";
>
> }} until $x_calc > 7.5;
> $x_calc = $penultimate;
> }} until ($power > 6);
[...]
> Is there a slicker way to do this in perl than using the double curly
> braces?
Absolutely, here it goes for your main loop:
while ($power < 6 and $x_calc < 10) {
$x_calc++;
$power++;
print "x calc is $x_calc\n";
print "x_calc out is $x_calc\n";
print "power out is $power\n";
while ($x_calc <= 7.5 ){
$power++;
$x_calc++;
print "power in is $power\n";
print "x_calc in is $x_calc\n";
}
$x_calc = $penultimate;
};
It also reduced the number of lines from 20 to 14 and IMHO is much more
readable, too.
jue
Re: equivalent controls
am 29.11.2007 05:21:41 von Wade Ward
"Jürgen Exner" wrote in message
news:9Iq3j.17146$r81.5080@trndny05...
> Wade Ward wrote:
> [...]
>> do {{
>> $x_calc++;
>> $power++;
>>
>> last if $x_calc > 10;
>> print STDOUT "x calc is $x_calc\n";
>> print STDOUT "x_calc out is $x_calc\n";
>> print STDOUT "power out is $power\n";
>> do {{
>> $power++;
>> $x_calc++;
>> print STDOUT "power in is $power\n";
>> print STDOUT "x_calc in is $x_calc\n";
>> $x_sought = $x_sought - 1;
>> last if 1 > 0;
>> print STDOUT "x sought is $x_sought\n";
>>
>> }} until $x_calc > 7.5;
>> $x_calc = $penultimate;
>> }} until ($power > 6);
> [...]
>> Is there a slicker way to do this in perl than using the double curly
>> braces?
>
> Absolutely, here it goes for your main loop:
>
> while ($power < 6 and $x_calc < 10) {
> $x_calc++;
> $power++;
> print "x calc is $x_calc\n";
> print "x_calc out is $x_calc\n";
> print "power out is $power\n";
> while ($x_calc <= 7.5 ){
> $power++;
> $x_calc++;
> print "power in is $power\n";
> print "x_calc in is $x_calc\n";
> }
> $x_calc = $penultimate;
> };
>
> It also reduced the number of lines from 20 to 14 and IMHO is much more
> readable, too.
It sure looks like I'm torturing the syntax, but I got contract68 to work:
## contract68.pl
## one sided increasingly good guesses
## contributors: joe smith, jean luc, Jürgen Exner
use strict;
use warnings;
my $x_calc = 5.3;
my $x_sought = 7.321928094887362;
my $base = .5;
my $term = -.00057;
my $penultimate = -.00057;
my $cows_come_home = 0;
my $power = 1;
do {{
$term = $base**$power;
print STDOUT "term is $term \n";
print STDOUT "current is $penultimate \n";
$power++;
do {{
$penultimate = $x_calc;
$x_calc = $x_calc + $term;
# end inner do
# last if (10.0*(2.0**$x_calc) > 1600.0);
}} until (10.0*(2.0**$x_calc) > 1600.0);
$x_calc = $penultimate;
# end outer do
}} until ($power > 35);
$x_calc = $penultimate;
print STDOUT "x_calc output is $x_calc\n";
print STDOUT "x_sought output is $x_sought\n";
print STDOUT "sig figs output is 1.23456789112345 $cows_come_home\n";
# perl contract68.pl
# perl contract68.pl 2>text55.txt >text56.txt
__END__
#end script begin output
term is 0.5
current is -0.00057
term is 0.25
current is 7.3
term is 0.125
current is 7.3
term is 0.0625
current is 7.3
term is 0.03125
current is 7.3
term is 0.015625
current is 7.3
term is 0.0078125
current is 7.315625
term is 0.00390625
current is 7.315625
term is 0.001953125
current is 7.31953125
term is 0.0009765625
current is 7.321484375
term is 0.00048828125
current is 7.321484375
term is 0.000244140625
current is 7.321484375
term is 0.0001220703125
current is 7.321728515625
term is 6.103515625e-005
current is 7.3218505859375
term is 3.0517578125e-005
current is 7.32191162109375
term is 1.52587890625e-005
current is 7.32191162109375
term is 7.62939453125e-006
current is 7.32192687988281
term is 3.814697265625e-006
current is 7.32192687988281
term is 1.9073486328125e-006
current is 7.32192687988281
term is 9.5367431640625e-007
current is 7.32192687988281
term is 4.76837158203125e-007
current is 7.32192783355713
term is 2.38418579101563e-007
current is 7.32192783355713
term is 1.19209289550781e-007
current is 7.32192807197571
term is 5.96046447753906e-008
current is 7.32192807197571
term is 2.98023223876953e-008
current is 7.32192807197571
term is 1.49011611938477e-008
current is 7.32192807197571
term is 7.45058059692383e-009
current is 7.32192808687687
term is 3.72529029846191e-009
current is 7.32192809432745
term is 1.86264514923096e-009
current is 7.32192809432745
term is 9.31322574615479e-010
current is 7.32192809432745
term is 4.65661287307739e-010
current is 7.32192809432745
term is 2.3283064365387e-010
current is 7.32192809479311
term is 1.16415321826935e-010
current is 7.32192809479311
term is 5.82076609134674e-011
current is 7.32192809479311
term is 2.91038304567337e-011
current is 7.32192809485132
x_calc output is 7.32192809488042
x_sought output is 7.32192809488736
sig figs output is 1.23456789112345 0
#end output begin comment
I hope that aligns.
I'll try to beautify with those same changes as you made above. Thx.
--
wade ward
wade@zaxfuuq.net
435 -838-7760
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Re: equivalent controls
am 29.11.2007 05:40:31 von jurgenex
Wade Ward wrote:
> "Jürgen Exner" wrote in message
> ## contributors: joe smith, jean luc, Jürgen Exner
Please remove my name. I would be ashamed to be associated with such code.
jue
Re: equivalent controls
am 29.11.2007 07:41:45 von Wade Ward
f'up reset
Vielleicht wollen wir uns lieber auf Deutsch unterhalten. Kannste bitte mal
op duuch erklaeren, was in Allerhäßlichkeit in diesem Program stattfindet?
Wird Dir leichter zu berlinern, wahr?
--
wade ward
wade@zaxfuuq.net
435 -838-7760
"Jürgen Exner" wrote in message
news:9Iq3j.17146$r81.5080@trndny05...
> Wade Ward wrote:
> [...]
>> do {{
>> $x_calc++;
>> $power++;
>>
>> last if $x_calc > 10;
>> print STDOUT "x calc is $x_calc\n";
>> print STDOUT "x_calc out is $x_calc\n";
>> print STDOUT "power out is $power\n";
>> do {{
>> $power++;
>> $x_calc++;
>> print STDOUT "power in is $power\n";
>> print STDOUT "x_calc in is $x_calc\n";
>> $x_sought = $x_sought - 1;
>> last if 1 > 0;
>> print STDOUT "x sought is $x_sought\n";
>>
>> }} until $x_calc > 7.5;
>> $x_calc = $penultimate;
>> }} until ($power > 6);
> [...]
>> Is there a slicker way to do this in perl than using the double curly
>> braces?
>
> Absolutely, here it goes for your main loop:
>
> while ($power < 6 and $x_calc < 10) {
> $x_calc++;
> $power++;
> print "x calc is $x_calc\n";
> print "x_calc out is $x_calc\n";
> print "power out is $power\n";
> while ($x_calc <= 7.5 ){
> $power++;
> $x_calc++;
> print "power in is $power\n";
> print "x_calc in is $x_calc\n";
> }
> $x_calc = $penultimate;
> };
>
> It also reduced the number of lines from 20 to 14 and IMHO is much more
> readable, too.
>
> jue
>
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Re: equivalent controls
am 29.11.2007 07:41:45 von Wade Ward
f'up reset
Vielleicht wollen wir uns lieber auf Deutsch unterhalten. Kannste bitte mal
op duuch erklaeren, was in Allerhäßlichkeit in diesem Program stattfindet?
Wird Dir leichter zu berlinern, wahr?
--
wade ward
wade@zaxfuuq.net
435 -838-7760
"Jürgen Exner" wrote in message
news:9Iq3j.17146$r81.5080@trndny05...
> Wade Ward wrote:
> [...]
>> do {{
>> $x_calc++;
>> $power++;
>>
>> last if $x_calc > 10;
>> print STDOUT "x calc is $x_calc\n";
>> print STDOUT "x_calc out is $x_calc\n";
>> print STDOUT "power out is $power\n";
>> do {{
>> $power++;
>> $x_calc++;
>> print STDOUT "power in is $power\n";
>> print STDOUT "x_calc in is $x_calc\n";
>> $x_sought = $x_sought - 1;
>> last if 1 > 0;
>> print STDOUT "x sought is $x_sought\n";
>>
>> }} until $x_calc > 7.5;
>> $x_calc = $penultimate;
>> }} until ($power > 6);
> [...]
>> Is there a slicker way to do this in perl than using the double curly
>> braces?
>
> Absolutely, here it goes for your main loop:
>
> while ($power < 6 and $x_calc < 10) {
> $x_calc++;
> $power++;
> print "x calc is $x_calc\n";
> print "x_calc out is $x_calc\n";
> print "power out is $power\n";
> while ($x_calc <= 7.5 ){
> $power++;
> $x_calc++;
> print "power in is $power\n";
> print "x_calc in is $x_calc\n";
> }
> $x_calc = $penultimate;
> };
>
> It also reduced the number of lines from 20 to 14 and IMHO is much more
> readable, too.
>
> jue
>
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Re: equivalent controls
am 29.11.2007 11:54:04 von merl the perl
"Wade Ward" wrote in message
news:1196318029_707@sp12lax.superfeed.net...
> Typ sagt:
> Vielleicht wollen wir uns lieber auf Deutsch unterhalten. Kannste bitte
> mal op duuch erklaeren, was in Allerhäßlichkeit in diesem Program
> stattfindet?
>
> Wird Dir leichter zu berlinern, wahr?
>> It also reduced the number of lines from 20 to 14 and IMHO is much more
>> readable, too.
>>
>> jue
## contract71.pl
## one sided increasingly good guesses
## contributors: ne-kto nyet
use strict;
use warnings;
my $x_calc = 5.3;
my $x_sought = 7.321928094887362;
my $base = .1;
my $term = -.00057;
my $penultimate = -.00057;
my $cows_come_home = 0;
my $power = 1;
# ($power > 35)
do {{
$term = $base**$power;
print STDOUT "term is $term \n";
print STDOUT "current is $penultimate \n";
$power++;
do {{
$penultimate = $x_calc;
$x_calc = $x_calc + $term;
}} until (10.0*(2.0**$x_calc) > 1600.0);
$x_calc = $penultimate;
# end outer do
}} until ($power > 12);
$x_calc = $penultimate;
# ($power > 35) (10.0*(2.0**$x_calc) > 1600.0)
# $juergens_schild $mein_schatzenfreude
#> while ($power < 6 and $x_calc < 10) {
#> $x_calc++;
#> $power++;
#> print "x calc is $x_calc\n";
#> print "x_calc out is $x_calc\n";
#> print "power out is $power\n";
#> while ($x_calc <= 7.5 ){
#> $power++;
#> $x_calc++;
#> print "power in is $power\n";
#> print "x_calc in is $x_calc\n";
#> }
#> $x_calc = $penultimate;
#> };
print STDOUT "x_calc output is $x_calc\n";
print STDOUT "x_sought output is $x_sought\n";
print STDOUT "sig figs output is 1.23456789112345 $cows_come_home\n";
# perl contract71.pl
# perl contract71.pl 2>text55.txt >text56.txt
__END__
--
drah die nit um
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Re: equivalent controls
am 29.11.2007 17:13:30 von Ted Zlatanov
On Thu, 29 Nov 2007 04:40:31 GMT "Jürgen Exner" wrote:
JE> Wade Ward wrote:
>> "Jürgen Exner" wrote in message
>> ## contributors: joe smith, jean luc, Jürgen Exner
JE> Please remove my name. I would be ashamed to be associated with such code.
Don't be so modest, you could collect on the royalties! :)
Ted
Re: equivalent controls
am 29.11.2007 23:54:39 von Michele Dondi
On Wed, 28 Nov 2007 21:21:41 -0700, "Wade Ward"
wrote:
>> while ($power < 6 and $x_calc < 10) {
>> $x_calc++;
>> $power++;
>> print "x calc is $x_calc\n";
>> print "x_calc out is $x_calc\n";
>> print "power out is $power\n";
>> while ($x_calc <= 7.5 ){
>> $power++;
>> $x_calc++;
>> print "power in is $power\n";
>> print "x_calc in is $x_calc\n";
>> }
>> $x_calc = $penultimate;
>> };
>>
>> It also reduced the number of lines from 20 to 14 and IMHO is much more
>> readable, too.
>It sure looks like I'm torturing the syntax, but I got contract68 to work:
[snip]
> do {{
>$term = $base**$power;
>print STDOUT "term is $term \n";
>print STDOUT "current is $penultimate \n";
I can't understand... Juergen posted code that's equivalent to yours
but looks much cleaner and more readable. Why are you throwing in this
do {{ madness again?
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,