aliquote.org

July 8, 2019

Best way I found to mimic R’s rle function is this nice little piece of code (in Racket; credit to Chris Jester-Young):

(define (bagify lst)
  (foldl (lambda (key ht)
           (hash-update ht key add1 0))
         #hash() lst))