Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

think of a better name than fold/hash-table

Name: Anonymous 2007-11-30 14:12

;; Walks along `list' and for each item calls `proc' with the current item and a value
;; from the hash-table, the key of which is based on calling `identifier` with the
;; current item. The initial value for each hash-table entry is based on calling
;; `initial' on the first item satisfying `identifier'. The return value of `proc'
;; is used to set the hash-table entry.
  (define (fold/hash-table list identifier proc initial)
    (let ((table (make-hash-table 'equal)))
      (for-each
       (lambda (item)
         (let* ((key (identifier item))
                (new-value (proc item (hash-table-get table key (initial item)))))
           (hash-table-put! table key new-value)))
       list)
      table))

Name: Anonymous 2007-11-30 18:38

>>12
One word, #|foo|#, thread continues.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List