[racket] Apply proc with hasheq

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Dec 18 09:11:02 EST 2012

7 hours ago, Danny Yoo wrote:
> (define (hash->keyword-apply f a-hash [rest-args '()])
>   (define-values (keys vals)
>     (for/fold ([keys '()] [vals '()])
>               ([k (sort (hash-keys a-hash) string>? #:key symbol->string)])
>       (values (cons (string->keyword (symbol->string k)) keys)
>               (cons (hash-ref a-hash k) vals))))
>   (keyword-apply f keys vals rest-args))

`keyword<?' would be easier.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the users mailing list.