splitting-butlastGBBopen Toolssortfsorted-maphashGoTo Top

sorted-maphash   function hash-table predicate &key key[Function]

Purpose
Apply a function once to each of the entries in a hash table according to the entry-key order determined by the predicate function

Package   :gbbopen-tools

Module   :gbbopen-tools

Arguments and values

function     A function designator specifying a function object of two arguments, the key and value of the hash-table entry
hash-table     A hash table
predicate     A function designator specifying a function object of two arguments that returns a generalized boolean
key     A function designator specifying a function object of one argument, or nil (default is nil)

Description
For each entry in the hash table, the function is called with two arguments–the key and the value of that entry.

The first argument to the predicate function is the key of one entry in the hash table (or part of that key extracted by the key function, if supplied); the second argument is the key of another entry in the hash table (or part of that key extracted by the key function, if supplied). The predicate function should return true if and only if the first argument is strictly less than the second; otherwise the predicate should return false.

Example
Print a list of entries in hash-table, in ascending order of their keys (which are strings):

  (sorted-maphash
     #'(lambda (key value)
         (format t "~&;; key: ~s value: ~s~%" key value)
     hash-table
     #'string<)


The GBBopen Project


splitting-butlastGBBopen Toolssortfsorted-maphashGoTo Top