[racket] (procedure? (hash)) -> true
On 08/05/2013 11:30 AM, John Griffin wrote:
> Thanks in advance for any advice leading to more succinct hash access.
Had you considered something along the lines of
(define (handier-style data)
   (when (@ data 'COMPANY)
     (db-exec ... (@ data 'COMPANY))))
?
You might start from
(define (@ base . path)
   (match path
     ['() base]
     [(cons (? number? n) rest)
      (apply @ (list-ref base n) rest)]
     [(cons (? symbol? k) rest)
      (apply @ (hash-ref base k) rest)]
     [... maybe other things ...]))
to give yourself a not-quite-XPath-like means of projecting JSON values.
Interesting design decisions include: what to do when a list index is 
out of range, or a hash key is not present? (Error? Terminate early 
returning some kind of "undefined" value?)
Cheers,
   Tony