Skip to content

Comment on Ask HN: How is the avg in my HN profile calculated?

Comments

I marked up the code pointed to by mrduncan with comments (a semicolon begins a comment in Arc).

  (def comment-score (user)
    (aif ;; (aif test true-part false-part) ;; if test is true, assign its value
                                            ;; to the variable it and evaluate
                                            ;; true-part. Otherwise, evaluate
                                            ;; false-part.
         ;; This could alternately be awhen, and leave out nil at the end
         ;; of this function
     (check (nthcdr 5 (comments user 50))
  	  [len> _ 10]) ;; if the user has at least 15 comments, assign
                       ;; the comments numbered 6-50 to the variable it
     (avg ;; get the average of the list returned from the next line
      (cdr ;; take every score but the first
  	 (sort > ;; order the scores, so the "first" score mentioned above is
                 ;; the highest-scoring one
  	       (map !score (rem !deleted it))))) ;; get the scores of each comment
                                                 ;; as a list
     nil))
So it takes your comments numbered 6-50, throws out the highest-scoring one, and averages them. This is assuming the code posted by mrduncan is still correct (I'm not digging through a fresh copy of the source right now).
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.