;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/survivor.el (require 'cl-lib) (require 'math) (defun five-mean (one two three four five) (move-end-of-line nil) (insert (format " [mean %s%%]" (round (mean-value (list one two three four five))) ))) (defun read-votes () (interactive) (let*((vts-str (thing-at-point 'symbol t)) (vts-strs (split-string vts-str "-")) (vts (cl-map 'list #'string-to-number vts-strs)) (str (apply #'votes vts)) ) (move-end-of-line nil) (insert " " str) )) (defun votes (&rest votes) (let*((vts (sort votes #'>=)) (num (apply #'+ vts)) (win (car vts)) (per (percent win num t)) ) per) ) (defun cost-at-day (day) (apply #'+ (number-sequence 1 day)) ) ;; (cost-at-day 48) ; 1176 AUS ;; (cost-at-day 39) ; 780 USA old era ;; (cost-at-day 28) ; 406 SWE ;; (cost-at-day 27) ; 378 USA new era ;; (cost-at-day 1) ; 1 ;; (cost-at-day 0) ; 0 (provide 'survivor)