IIUC in SQL this would simply be: SELECT student, AVG(rating) FROM scores GROUP BY student
Apparently a DSL for querying tables can be handy. :) The Racket equivalent for the special case of a 2-column table (a hash-table) could be something like: (define (sql-ish-aggregate-group-by f xs) (for/hash ([(k v) (in-hash (for/fold ([ht (hash)]) ; a "gather" ([x (in-list xs)]) (match-define (list k v) x) (hash-update ht k (λ (vs) (cons v vs)) '())))]) (cons k (f v)))) "Group by" seems to be a Rorschach phrase; overloaded meanings. Clojure has a group-by that differs from SQL or unstable/list. I don't know Clojure well enough to code golf this. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.