How to turn a list into a hash table?

hi guys! i recently started learning racket and still wrestle with some basic constructs.
how can i write something like this:

(list-to-hashtable (list (λ (list-item) (create-hashtable-key-from-list-item list-item))))

Thank you!


Well... it's not clear to me how your input list is formatted. Maybe it's a list of lists? Here's an example that might do what you want.

#lang racket

(define l
  '((a 4)
    (b 9)
    (c 24)))

 (map (λ (pr) (cons (first pr) (second pr))) l))

I can imagine ALL KINDS of reasons why this might not be what you want. Tell us if this isn't what you were looking for.


thank you! i didn't know there was a way to create a hastable from a list of pairs. have a nice day :slight_smile: