resyntax
resyntax copied to clipboard
Replace `hash-for-each` with `for`
#lang resyntax/test
test: "hash-for-each should be refactored to for"
--------------------
#lang racket
(define (f h)
(hash-for-each h (lambda (key val) (printf "key = ~a, val = ~a\n" key val))))
--------------------
--------------------
#lang racket
(define (f h)
(for ([(key val) (in-hash h)])
(printf "key = ~a, val = ~a\n" key val)))
--------------------
Should be similar to the for-each and map to for/list rules, where it's only refactored if the function given to hash-for-each is sufficiently complex.