Skip to content

Instantly share code, notes, and snippets.

@agumonkey
Last active December 15, 2015 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agumonkey/5262249 to your computer and use it in GitHub Desktop.
Save agumonkey/5262249 to your computer and use it in GitHub Desktop.
(require 'dash)
(defvar *hw/percent* 0.9)
(defvar *pr/percent* 0.1)
(defvar *week/percent* 0.1)
(defvar *exam/percent* 0.15)
(defun weekly-grades (hp)
(let ((hw (car hp))
(pr (cdr hp)))
(* *week/percent*
(+ (* *hw/percent* hw)
(* *pr/percent* pr)))))
(defun exam-grades (xm)
(* *exam/percent* xm))
(defun avg (reals)
(let ((count (length reals))
(sum (apply #'+ reals)))
(/ sum count)))
(defun final-grade (weekly/w exam/w)
(let ((weighted-grades (append weekly/w exam/w)))
(apply #'+ weighted-grades)))
(defun epilog (grade)
(format "Your final grade is %f ." grade))
;;; main
(setq hws '(47 100 65 100 100 100 50))
(setq prs '(30 30 30 30 30 30 30))
(setq xms '(95 95))
(epilog
(final-grade (-map 'weekly-grades (-zip hws prs))
(-map 'exam-grades xms)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment