Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #21615
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: post your solution to this problem |
| Date | 2013-04-12 00:56 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <kk7m48$krj$1@dont-email.me> (permalink) |
| References | <85acf1b9-9524-4814-8692-b88662dabe03@ki5g2000pbb.googlegroups.com> <70a873a7-a93e-4ac1-a030-4566a4ac17d9@googlegroups.com> <7deb5fab-5eca-424a-bde6-334ee7f3da4a@m3g2000vbl.googlegroups.com> <kjnpji$unf$1@dont-email.me> |
WJ wrote:
> quiet_lad wrote:
>
> > 1984-85 21 PHI NBA 82 2347 1148 14.0 427 783 .545 293 400
> > .733 1 6 .167 266 437 703 8.6 155 1.9 95 80 209 301
> > 1985-86 22 PHI NBA 80 2952 1603 20.0 595 1041 .572 396 578
> > .685 17 75 .227 354 672 1026 12.8 312 3.9 173 125 350
> > 333
> > 1986-87 23 PHI NBA 68 2740 1564 23.0 557 937 .594 429 564
> > .761 21 104 .202 390 604 994 14.6 331 4.9 119 104 322
> > 252 A
> > 1987-88 24 PHI NBA 80 3170 2264 28.3 753 1283 .587 714 951
> > .751 44 157 .280 385 566 951 11.9 254 3.2 100 103 304
> > 278 N A
> > 1988-89 25 PHI NBA 79 3088 2037 25.8 700 1208 .579 602 799
> > .753 35 162 .216 403 583 986 12.5 325 4.1 126 67 254 262
> > N A
> > 1989-90 26 PHI NBA 79 3085 1989 25.2 706 1177 .600 557 744
> > .749 20 92 .217 361 548 909 11.5 307 3.9 148 50 243 250
> > N A
> > 1990-91 27 PHI NBA 67 2498 1849 27.6 665 1167 .570 475 658
> > .722 44 155 .284 258 422 680 10.1 284 4.2 110 33 210 173
> > N A
> > 1991-92 28 PHI NBA 75 2881 1730 23.1 622 1126 .552 454 653
> > .695 32 137 .234 271 559 830 11.1 308 4.1 136 44 235 196
> > A Log
> > 1992-93 29 PHO NBA 76 2859 1944 25.6 716 1376 .520 445 582
> > .765 67 220 .305 237 691 928 12.2 385 5.1 119 74 233 196
> > M N A Log
> > 1993-94 30 PHO NBA 65 2298 1402 21.6 518 1046 .495 318 452
> > .704 48 178 .270 198 529 727 11.2 296 4.6 101 37 206 160
> > Log
> > 1994-95 31 PHO NBA 68 2382 1561 23.0 554 1141 .486 379 507
> > .748 74 219 .338 203 553 756 11.1 276 4.1 110 45 150 201
> > A Log
> > 1995-96 32 PHO NBA 71 2632 1649 23.2 580 1160 .500 440 566
> > .777 49 175 .280 243 578 821 11.6 262 3.7 114 56 218 208
> > A Log
> > 1996-97 33 HOU NBA 53 2009 1016 19.2 335 692 .484 288 415
> > .694 58 205 .283 212 504 716 13.5 248 4.7 69 25 151 153
> > A Log
> > 1997-98 34 HOU NBA 68 2243 1036 15.2 361 744 .485 296 397
> > .746 18 84 .214 241 553 794 11.7 217 3.2 71 28 147 187
> > Log
> > 1998-99 35 HOU NBA 42 1526 676 16.1 240 502 .478 192 267 .
> > 719 4 25 .160 167 349 516 12.3 192 4.6 43 13 100 89
> > Log
> > 1999-00 36 HOU NBA 20 620 289 14.5 106 222 .477 71 110 .
> > 645 6 26 .231 71 138 209 10.5 63 3.2 14 4 44 48
> >
> > from http://databasebasketball.com/players/playerpage.htm?ilkid=BARKLCH01
> >
> > awk '{print $7/($10+($13/2))}' player_stats_file|sort -rn
> >
> > [g@pelias ~/hoops]$ cat pps.tcl
> > #! /usr/local/bin/tclsh8.6
> > set tcl_precision 4
>
> The manual says never to set tcl_precision.
>
>
> > set infile [open "moses" r]
> > set data [read $infile]
> > set lines [split $data "\n"]
> > foreach line $lines {
> > if {[llength $line] > 0} {
> > set year [lindex $line 0]
> > set p [lindex $line 6]
> > set fga [lindex $line 9]
> > set fta [lindex $line 12]
> > set tg [expr {double($fga)+($fta/2)}]
>
> Mathematically wrong. 9/2 = 4, which is not what you want.
>
>
> > set pps [expr {$p/$tg}]
> > lappend unsorted "$pps $year"
> > }
> > }
> > set sorted [lsort -index 0 -decreasing $unsorted]
>
> The sort command should be given the -real option.
>
>
> > foreach x $sorted {
> > puts $x
> > }
> > close $infile
> > set tcl_precision 0
>
> package require fileutil
> set unsorted {}
> ::fileutil::foreachLine line "moses.txt" {
> foreach {year . . . . . p . . fga . . fta} $line break
> set tg [ expr {$fga + $fta * 0.5} ]
> lappend unsorted "[expr {$p/$tg}] $year"
> }
> foreach x [lsort -index 0 -decreasing -real $unsorted] {
> puts [format "%.4f %s" {*}$x] }
>
> 1.2875 1987-88
> 1.2841 1989-90
> 1.2830 1986-87
> 1.2672 1988-89
> 1.2360 1990-91
> 1.2053 1985-86
> 1.1910 1991-92
> 1.1679 1984-85
> 1.1662 1992-93
> 1.1428 1995-96
> 1.1295 1996-97
> 1.1194 1994-95
> 1.1022 1993-94
> 1.0992 1997-98
> 1.0637 1998-99
> 1.0433 1999-00
Another Tcl version:
package require fileutil
namespace path {::tcl::mathop ::tcl::mathfunc}
set unsorted {}
::fileutil::foreachLine line "moses.txt" {
lassign $line year . . . . . p . . fga . . fta
set tg [+ $fga [* $fta 0.5]]
lappend unsorted [/ $p $tg] $year
}
foreach {x year} [lsort -stride 2 -decreasing -real $unsorted] {
puts [format "%.4f %s" $x $year]}
1.2875 1987-88
1.2841 1989-90
1.2830 1986-87
1.2672 1988-89
1.2360 1990-91
1.2053 1985-86
1.1910 1991-92
1.1679 1984-85
1.1662 1992-93
1.1428 1995-96
1.1295 1996-97
1.1194 1994-95
1.1022 1993-94
1.0992 1997-98
1.0637 1998-99
1.0433 1999-00
Back to comp.lang.forth | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: post your solution to this problem "WJ" <w_a_x_man@yahoo.com> - 2013-04-06 00:17 +0000 Re: post your solution to this problem "WJ" <w_a_x_man@yahoo.com> - 2013-04-06 02:23 +0000 Re: post your solution to this problem "WJ" <w_a_x_man@yahoo.com> - 2013-04-12 00:56 +0000
csiph-web