On 10/12/2021 7:01 PM, unlimitedscolobb wrote:
I wrote myself this little function:

(define (hash->ordered-list h)
  (hash-map h cons #t))

which uses the try-order? argument of hash-map.

Is there a reason for hash->list not have an optional argument try-order?  Or perhaps having such a standalone function would be better?

I was planning to submit a patch, but then I thought I may be missing something.

-
Sergiu


I can't speak for the Racket team, but ...

Hash tables entries inherently are unordered, so there really is no reason to expect an ordered list from reading out the data.  Also, the docs indicate that 'try-order?' doesn't work for all data types - so it may produce unexpected results.  Further, sorting the output potentially can take a lot of extra time ... having never tried to get ordered output from hash-map, I can only hypothesize that (at least in some cases) it may be faster to create the unordered list and then sort it than to try to produce an ordered list with 'try-order?'.

Certainly, you are welcome to submit a change, but I think it would be best to leave the existing behavior and make ordered output an addition.

YMMV,
George

--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/a30ae67d-891e-82f5-f3be-cc1fc1f89263%40comcast.net.

Reply via email to