Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.lisp
Re: beyond fizzbuzz to NBA stats! compute point per shot! clisp problemplease post an answer
William James
6/11/2016 7:54:00 PM
endlessboomcapitalism@gmail.com wrote:
> I like basketball.
>
> I love to use awk to compute point per shot.
>
> The point per shot is points per game divided by field goal and half free throw attempts.
>
> I notice that Kevin McHale has a very high point per shot.
>
>
http://www.basketball-reference.com/players/m/mcha...
>
> see section "per game" stats, and I copy into file named mchale.
Why did you have to copy and paste? Why are you manually doing
the work that your program should be doing?
Why not just give the URL to the program and let it do everything?
>
> I had to remove the * star next to some rows in column one manually in vi editor.
Why are you manually doing the work that your program should be doing?
>
> There are also some blanks for 3p% that I filled in with 0 in row for 82 86 and 88.
Why are you manually doing the work that your program should be doing?
>
> Once all the rows are filled and each column is not blank and free of stars.
>
> Now awk can compute the point per shot, print the year, and sort -rn can sort:
Why do you have to use the Unix sort utility?
Doesn't your programming language know how to sort?
>
> $ awk '{print $30/($10+($20/2)), $1}' mchale |sort -rn
Your program does next to nothing.
Most of the work is done by you, your web browser, and sort.
> 1.28571 1986-87
> 1.28409 1987-88
> 1.22222 1989-90
> 1.21714 1985-86
> 1.21101 1984-85
> 1.19481 1990-91
> 1.19048 1988-89
> 1.17949 1983-84
> 1.12351 1982-83
> 1.11475 1981-82
> 1.10497 1980-81
> 1.0902 1991-92
Not enough digits in the number!
The alignment is ruined!
> 1.02392 1992-93
When one uses MatzLisp (Ruby), he can make the program
do it all.
require "open-uri"
html =
open("
http://www.basketball-reference.com/players/m/mcha...
"){|handle|
handle.read}
# Extract the rows of data.
raw_rows = html.scan( %r{<tr [^>]*id="per_game.\d+">(.*?)</tr>}m ).flatten
rows = raw_rows.map{|row|
row.scan( %r{<td[^>]+>(.*?)</td>} ).flatten.
map{|str| Float(str) rescue str}}
result = rows.map{|row|
[row[29]/(row[9] + row[19]/2), row[0][/\d{4}-\d\d/]]}.
sort.reverse
result.each{|x,s| printf "%.5f %s\n", x, s}
1.28571 1986-87
1.28409 1987-88
1.22222 1989-90
1.21714 1985-86
1.21101 1984-85
1.19481 1990-91
1.19048 1988-89
1.17949 1983-84
1.12351 1982-83
1.11475 1981-82
1.10497 1980-81
1.09020 1991-92
1.02392 1992-93
--
Jews totally run Hollywood.... But I don't care if Americans think we're
running the news media, Hollywood, Wall Street or the government. I just care
that we get to keep running them. --- Joel Stein
archive.org/download/DavidDukeTv/DoJewsControlTheMediaTheLaTimesSaysYes.flv
articles.latimes.com/2008/dec/19/opinion/oe-stein19
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: beyond fizzbuzz to NBA stats! compute point per shot! clisp problemplease post an answer
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password