Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
[[tags: egg callable-data-structures]] == callable-data-structures [[toc:]] === Introduction This egg provides "callable" data structures (lists, alists, vectors, hash tables and strings). "Callable" data structures are actually special procedures that internally hold a data structure. Here's an example: <enscript highlight=scheme> #;1> (use callable-alists) #;2> (define alist (make-callable-alist)) #;3> alist #<procedure callable-alist> #;4> (alist 'foo) #f #;5> (alist 'foo 'not-set) not-set #;6> (set! (alist 'foo) 42) #;7> (alist 'foo) 42 </enscript> When called without arguments, "callable" data structures return their internal data structure, so you can apply any accessor compatible with them. Example: <enscript highlight=scheme> #;1> (use callable-hash-tables) #;2> (define hash-table (make-callable-hash-table)) #;3> (hash-table-exists? (hash-table) 'foo) #f #;4> (set! (hash-table 'foo) 42) #;5> (hash-table-exists? (hash-table) 'foo) #t #;6> (hash-table 'foo) 42 </enscript> === Author [[http://wiki.call-cc.org/users/mario-domenech-goulart|Mario Domenech Goulart]] === Repository [[https://github.com/mario-goulart/callable-data-structures|https://github.com/mario-goulart/callable-data-structures]] === Requirements None === API This extension provides a separate module for each supported data structure. So, the following modules are available: * {{callable-alists}} * {{callable-hash-tables}} * {{callable-lists}} * {{callable-strings}} * {{callable-vectors}} It also provides a {{callable-data-structures}} which exports all symbols from all modules. ==== Module {{callable-alists}} ===== {{make-callable-alist}} <procedure>(make-callable-alist #!optional (alist '()) #!key (test eqv?))</procedure> Return a callable alist object. The initial alist is optional if the {{test}} keyword parameter is not given. The {{test}} keyword parameter specifies the key comparison procedure (default: {{eqv?}}). Besides the alist key, the callable alist object accepts the {{default}} keyword parameter, which specifies the default value for when the given key doesn't exist (default: {{#f}}). Examples: <enscript highlight=scheme> #;1> (use callable-alists) #;2> (define symbols (make-callable-alist)) #;3> symbols #<procedure callable-alist> #;4> (symbols) () #;5> (set! (symbols 'foo) 42) #;6> (symbols 'foo) 42 #;7> (symbols) ((foo . 42)) #;8> (define strings (make-callable-alist '() test: equal?)) #;9> strings #<procedure callable-alist> #;10> (strings) () #;11> (set! (strings "foo") 42) #;12> (strings "foo") 42 #;13> (strings) (("foo" . 42)) </enscript> ===== {{callable-alist?}} <procedure>(callable-alist? obj)</procedure> Type predicate. Return {{#t}} if {{obj}} is a callable alist or {{#f}} if it is not. ==== Module {{callable-hash-tables}} ===== {{make-callable-hash-table}} <procedure>(make-callable-hash-table . args)</procedure> Return a callable hash table object. The initial value is an alist, and it is optional if no other keyword parameter is provided. All the keyword parameters for [[http://wiki.call-cc.org/man/4/Unit%20srfi-69#make-hash-table|{{make-hash-table}}]] are valid for {{make-callable-hash-table}}. Examples: <enscript highlight=scheme> #;1> (use callable-hash-tables) #;2> (define hash-table (make-callable-hash-table)) #;3> hash-table #<procedure callable-hash-table> #;4> (hash-table) #<hash-table (0)> #;5> (set! (hash-table 'foo) 42) #;6> (hash-table 'foo) 42 </enscript> <enscript highlight=scheme> #;1> (use callable-hash-tables) #;2> (define hash-table (make-callable-hash-table '((foo . 42) (bar . 0)))) #;3> (hash-table 'foo) 42 #;4> (hash-table 'bar) 0 </enscript> <enscript highlight=scheme> #;1> (use callable-hash-tables) #;2> (define hash-table (make-callable-hash-table '(("foo" . 42) ("bar" . 0)) test: equal?)) #;3> (hash-table "foo") 42 #;4> (hash-table "bar") 0 </enscript> ===== {{callable-hash-table?}} <procedure>(callable-hash-table? obj)</procedure> Type predicate. Return {{#t}} if {{obj}} is a callable hash table or {{#f}} if it is not. ==== Module {{callable-lists}} ===== {{make-callable-list}} <procedure>(make-callable-list . items)</procedure> Return a callable list object. It accepts an arbitrary number if items. Example: <enscript highlight=scheme> #;1> (use callable-lists) #;2> (define l (make-callable-list "foo" "bar" "baz")) #;3> l #<procedure callable-list> #;4> (l) ("foo" "bar" "baz") #;5> (l 2) "baz" #;6> (set! (l 1) "quux") #;7> (l) ("foo" "quux" "baz") </enscript> ===== {{callable-list?}} <procedure>(callable-list? obj)</procedure> Type predicate. Return {{#t}} if {{obj}} is a callable list or {{#f}} if it is not. ==== Module {{callable-strings}} ===== {{make-callable-string}} <procedure>(make-callable-string . chars)</procedure> Return a callable string object. It accepts an arbitrary number of characters. Example: <enscript highlight=scheme> #;1> (use callable-strings) #;2> (define s (make-callable-string #\f #\o #\o)) #;3> s #<procedure callable-string> #;4> (s) "foo" #;5> (s 1) #\o #;6> (set! (s 0) #\d) #;7> (s) "doo" </enscript> ===== {{callable-string?}} <procedure>(callable-string? obj)</procedure> Type predicate. Return {{#t}} if {{obj}} is a callable string or {{#f}} if it is not. ==== Module {{callable-vectors}} ===== {{make-callable-vector}} <procedure>(make-callable-vector . items)</procedure> Return a callable vector object. It accepts an arbitrary number of items. Example: <enscript highlight=scheme> #;1> (use callable-vectors) #;2> (define v (make-callable-vector 'foo "bar" 42)) #;3> v #<procedure callable-vector> #;4> (v) #(foo "bar" 42) #;5> (v 1) "bar" #;6> (set! (v 1) "quux") #;7> (v) #(foo "quux" 42) </enscript> ===== {{callable-vector?}} <procedure>(callable-vector? obj)</procedure> Type predicate. Return {{#t}} if {{obj}} is a callable vector or {{#f}} if it is not. === Limitations Callable data strucutures are special procedures, but still procedures, which means the procedure predicate returns {{#t}} when given a callable data structure object: <enscript highlight=scheme> #;1> (use callable-alists) #;2> (define alist (make-callable-alist)) #;3> (procedure? alist) #t #;4> (callable-alist? alist) #t </enscript> === License Copyright (c) 2013-2021, Mario Domenech Goulart All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. === Version history ==== Version 1.0.3 (2021-04-17) * Fix component build dependencies for the build system of CHICKEN 5 (irrelevant for CHICKEN 4) ==== Version 1.0.2 * CHICKEN 5 support ==== Version 1.0.1 * Bug fix: reexport {{callable-alists}} from {{callable-data-structures}} ==== Version 1.0 * Initial release
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you subtract 23 from 10?