Danny,<br><br>It's a really amazing function. <br><br>I wonder when keyword arguments are passed into a procedure, are those arguments sorted by evaluator?<br><br>John,<br><br>I never use match liking this. I really should re-read match manual again.<br>
<br>Thanks,<br>Haiwei<br><div class="gmail_extra"><br><br><div class="gmail_quote">On 18 December 2012 15:11, Danny Yoo <span dir="ltr"><<a href="mailto:dyoo@hashcollision.org" target="_blank">dyoo@hashcollision.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The function I provided for hash->keyword-apply is unfortunately<br>
broken; I forgot that there's a requirement on the order of the<br>
keywords we pass to it. Here's a revised version:<br>
<br>
<br>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>
<div class="im">(define (hash->keyword-apply f a-hash [rest-args '()])<br>
(define-values (keys vals)<br>
(for/fold ([keys '()] [vals '()])<br>
</div> ([k (sort (hash-keys a-hash) string>? #:key symbol->string)])<br>
<div class="im"> (values (cons (string->keyword (symbol->string k)) keys)<br>
</div> (cons (hash-ref a-hash k) vals))))<br>
<div class="im"> (keyword-apply f keys vals rest-args))<br>
</div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>
</blockquote></div><br></div>