help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ice-hockey World Juniors 2020 / Elisp database, and more [4th attempt]


From: Emanuel Berg
Subject: ice-hockey World Juniors 2020 / Elisp database, and more [4th attempt]
Date: Sat, 18 Jan 2020 17:35:52 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

(This is the _fourth_ time I try to post this!
I hope no one ... whatever.)

The 2020 edition of the World Juniors has been
concluded with Canada beating Russia, while
Sweden beat Nordic rival Finland in the
Bronze Medal Game.

Here is a piece of Elisp including all data
necessary to do advanced calculations on "the
coolest game on Earth" (note to
non-programmers: there's a pun in that quote!)

>From a programmer's perspective it also shows
how one can easily do programming which applies
to the document where the code is, and this is
actually a very useful feature/method in
everyday programming, tho this example is
probably rare in that here, that is actually
the main purpose and not some clever
little helper.

This example also shows a thing that maybe gets
lost in today's bombastic database industry,
namely that a text file can be a database as
well! And no wonder that gets lost - if all
people did that, what need would there be for
a bombastic database industry?!

Anyway here is the file:
  https://dataswamp.org/~incal/hockey/jvm.el

( bonus: here is another file, if you don't care for
  today's youth:
    https://dataswamp.org/~incal/hockey/vm.el )

( bonus 2: because this post didn't get thru,
  I had time to do the Winter Olympics as well
  - with a fun fact about Russia, BTW :)
  they never won! or did they...
    https://dataswamp.org/~incal/hockey/os.el )  

But I yank jvm.el here, as well. If you view
this in Gnus, you can execute the functions
even here :)

As always, please provide feedback to the poor
programmer who wrote it, currently unemployed
by the bombastic database industry...

Note to non-programmers: etc etc

;; this file: https://dataswamp.org/~incal/hockey/jvm.el
;;
;; also see:  https://dataswamp.org/~incal/hockey/vm.el
;;      and:  https://dataswamp.org/~incal/hockey/os.el
;;
;;
;; source: 
https://en.wikipedia.org/wiki/List_of_IIHF_World_Under-20_Championship_medalists
;;
;;
;; Notes:
;;
;;   * Medal computation fallout _does_ include
;;     the three unofficial World Juniors, held
;;     in 1974, 1975, and 1976.
;;
;;   * In 1992, the winner was formally CIS,
;;     the "Commonwealth of Independent
;;     States". Instead of CIS, Russia is
;;     stated as winner for practical reasons.
;;
;;   * In 1993, the bronze was formally claimed
;;     by the "Czech, Slovak Republics". Here,
;;     Czechoslovakia is stated.

(defun jvm-find-gold (nation)
  (save-excursion
    (let*((search-string (concat ";; [0-9]\\{4\\} " nation))
          (years ()))
      (while (re-search-forward search-string (point-max) t)
        (push
         (string-to-number (substring (match-string 0) 3 7))
         years) )
      years) ))
;; (jvm-find-gold "Finland") ; (2019 2016 2014 1998 1987)
;; (jvm-find-gold "USA")     ; (2017 2013 2010 2004)
;; (jvm-find-gold "Sweden")  ; (2012 1981)

(defun jvm-how-many-medals (nation &optional position)
  (let*((position (or position 1))
        (col      (nth (1- position) '(8 23 38))) )
    (how-many
     (format "^.\\{%d\\}%s" col nation)
     (point-at-string "WJs")
     (point-max) )))

(defun jvm-point-at-string (s)
  (save-excursion
    (search-forward s)
    (point) ))

;; some interesting examples...

(when nil
  (jvm-how-many-medals "Canada" 1) ; 18
  (jvm-how-many-medals "Canada" 2) ; 11
  (jvm-how-many-medals "Canada" 3) ;  6

  (+ (jvm-how-many-medals "SSSR"   1) ; 11
     (jvm-how-many-medals "Russia" 1) ;  5
     )                                ; 16

  (jvm-how-many-medals "Finland" 1) ;  5
  (jvm-how-many-medals "Finland" 2) ;  5
  (jvm-how-many-medals "Finland" 3) ;  6

  (jvm-how-many-medals "USA" 1) ;  4
  (jvm-how-many-medals "USA" 2) ;  2
  (jvm-how-many-medals "USA" 3) ;  6

  (jvm-how-many-medals "Sweden" 1) ;  2
  (jvm-how-many-medals "Sweden" 2) ; 11
  (jvm-how-many-medals "Sweden" 3) ;  7

  (+ (jvm-how-many-medals "Czechoslovakia" 1) ;  0
     (jvm-how-many-medals "Czech Republic" 1) ;  2
     (jvm-how-many-medals "Slovakia"       1) ;  0
     )                                        ;  2
)

;;      gold           silver         bronze            unofficial WJs
;; -------------------------------------------------------------------
;; 1974 SSSR           Finland        Canada         Leningrad
;; 1975 SSSR           Canada         Sweden         Brandon, Winnipeg
;; 1976 SSSR           Canada         Czechoslovakia Pori, Rauna, Tampere, Turku
;;
;;
;;      gold           silver         bronze                IIHF IHWJC
;; -------------------------------------------------------------------
;; 1977 SSSR           Canada         Czechoslovakia  Banská Bystrica, Zvolen
;; 1978 SSSR           Sweden         Canada          Montreal, Quebec City
;; 1979 SSSR           Czechoslovakia Sweden          Karlskoga, Karlstad
;; 1980 SSSR           Finland        Sweden          Helsinki, Vantaa
;; 1981 Sweden         Finland        SSSR            Füssen, Kaufbeuren, 
Landsberg
;; 1982 Canada         Czechoslovakia Finland         Bloomington, Duluth, 
Minneapolis; Kenora, Winnipeg
;; 1983 SSSR           Czechoslovakia Canada          Leningrad
;; 1984 SSSR           Finland        Czechoslovakia  Norrköping, Nyköping
;; 1985 Canada         Czechoslovakia SSSR            Helsinki, Turku
;; 1986 SSSR           Canada         USA             Hamilton, London, Toronto
;; 1987 Finland        Czechoslovakia Sweden          Nitra, Pieštany, 
Topolčany, Trenčín
;; 1988 Canada         SSSR           Finland         Moscow
;; 1989 SSSR           Sweden         Czechoslovakia  Anchorage, Eagle River
;; 1990 Canada         SSSR           Czechoslovakia  Helsinki, Turku
;; 1991 Canada         SSSR           Czechoslovakia  Saskatoon, Regina
;; 1992 Russia         Sweden         USA             Füssen, Kaufbeuren
;; 1993 Canada         Sweden         Czechoslovakia  Falun, Gävle, Uppsala
;; 1994 Canada         Sweden         Russia          Frydek-Místek, Ostrava
;; 1995 Canada         Russia         Sweden          Calgary, Edmonton, Red 
Deer
;; 1996 Canada         Sweden         Russia          Amherst, Boston, 
Marlborough
;; 1997 Canada         USA            Russia          Geneva, Morges
;; 1998 Finland        Russia         Switzerland     Helsinki, Hämeenlinna
;; 1999 Russia         Canada         Slovakia        Brandon, Selkirk, Winnipeg
;; 2000 Czech Republic Russia         Canada          Skellefteå, Umeå
;; 2001 Czech Republic Finland        Canada          Moscow, Podolsk
;; 2002 Russia         Canada         Finland         Hradec Králové, Pardubice
;; 2003 Russia         Canada         Finland         Halifax, Sydney
;; 2004 USA            Canada         Finland         Helsinki, Hämeenlinna
;; 2005 Canada         Russia         Czech Republic  Grand Forks, Thief River 
Falls
;; 2006 Canada         Russia         Finland         Kamloops, Kelowna, 
Vancouver
;; 2007 Canada         Russia         USA             Leksand, Mora
;; 2008 Canada         Sweden         Russia          Liberec, Pardubice
;; 2009 Canada         Sweden         Russia          Ottawa
;; 2010 USA            Canada         Sweden          Saskatoon, Regina
;; 2011 Russia         Canada         USA             Buffalo, Lewiston
;; 2012 Sweden         Russia         Canada          Calgary, Edmonton
;; 2013 USA            Sweden         Russia          Ufa
;; 2014 Finland        Sweden         Russia          Malmö
;; 2015 Canada         Russia         Slovakia        Montreal, Toronto
;; 2016 Finland        Russia         USA             Helsinki
;; 2017 USA            Canada         Russia          Montreal, Toronto
;; 2018 Canada         Sweden         USA             Buffalo, Orchard Park
;; 2019 Finland        USA            Russia          Vancouver, Victoria
;; 2020 Canada         Russia         Sweden          Ostrava, Trinec


-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]