Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -0,0 +1,11 @@
|
|||
;; Create an associative array (hash-table) whose keys are strings:
|
||||
(define table (hash-table 'string=?
|
||||
'("hello" . 0) '("world" . 22) '("!" . 999)))
|
||||
|
||||
;; Iterate over the table, passing the key and the value of each entry
|
||||
;; as arguments to a function:
|
||||
(hash-table-for-each
|
||||
table
|
||||
;; Create by "partial application" a function that accepts 2 arguments,
|
||||
;; the key and the value:
|
||||
(pa$ format #t "Key = ~a, Value = ~a\n"))
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
;; Iterate over the table and create a list of the keys and the
|
||||
;; altered values:
|
||||
(hash-table-map
|
||||
table
|
||||
(lambda (key val) (list key (+ val 5000))))
|
||||
|
||||
;; Create a new table that has the same keys but altered values.
|
||||
(use gauche.collection)
|
||||
(map-to <hash-table>
|
||||
(lambda (k-v) (cons (car k-v) (+ (cdr k-v) 5000)))
|
||||
table)
|
||||
Loading…
Add table
Add a link
Reference in a new issue