@adamblan/

How-To-Use-Hashtables-In-Scheme

Scheme

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.3793667767444491","path":"main.scm","file":{"path":"main.scm","content":{"asEncoding":{"base64":"OyBjb25zdHJ1Y3RvcgooZGVmaW5lIGh0IChtYWtlLWhhc2h0YWJsZSBlcXVhbC1oYXNoIGVxdWFsPykpCgo7IHNldCB2YWx1ZSBmb3Iga2V5CihoYXNodGFibGUtc2V0ISBodCAia2V5IiAidmFsdWUiKQoKOyBjaGVjayBpZiBhIGtleSBoYXMgYSB2YWx1ZQoocHJpbnQgKGhhc2h0YWJsZS1jb250YWlucz8gaHQgImtleSIpKQoKOyBnZXQgYSB2YWx1ZSBmcm9tIGEgaGFzaCB0YWJsZQoocHJpbnQgInNob3VsZCBiZSB0aGVyZToga2V5ID0gIiAoaGFzaHRhYmxlLXJlZiBodCAia2V5IiAibm90IHRoZXJlIikpCihwcmludCAic2hvdWxkIE5PVCBiZSB0aGVyZTogZm9vID0gIiAoaGFzaHRhYmxlLXJlZiBodCAiZm9vIiAibm90IHRoZXJlIikp"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
; constructor
(define ht (make-hashtable equal-hash equal?))

; set value for key
(hashtable-set! ht "key" "value")

; check if a key has a value
(print (hashtable-contains? ht "key"))

; get a value from a hash table
(print "should be there: key = " (hashtable-ref ht "key" "not there"))
(print "should NOT be there: foo = " (hashtable-ref ht "foo" "not there"))
BiwaScheme Interpreter version 0.6.4 Copyright (C) 2007-2014 Yutaka HARA and the BiwaScheme team