Here is a possible implementation of the <tension> parameter. #!/usr/bin/perl
use strict;
my $plus = shift;
my $minus = shift;
my $sum = $plus + $minus;
my $rep = $plus - $minus;
my $mean = $rep / $sum;
#ALERT: semi-empirical formulae ahead
my $tension = (1 - $mean ** 2) * $sum * 2 / (2 - 1 / (1 + abs $rep));
$tension = log (1 + $tension) - 2;
my $literal;
for ($tension) {
$_ <= 0 and $literal = 'no', last;
$_ <= 1 and $literal = 'low', last;
$_ <= 2 and $literal = 'medium', last;
$literal = 'high';
}
printf <<"EOF", $plus, $minus, $rep, $tension, $literal;
Plus = %3d
Minus = %3d
Reputation = %3d
Tension = %.3f
There is %s tension on this post.
EOF
$|=$_="1g2i1u1l2i4e2n0k",map{print"\7",chop;select$,,$,,$,,$_/7}m{..}g
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|