- Timestamp:
- 04/08/20 20:18:08 (10 months ago)
- Location:
- release/5/hash-trie/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
release/5/hash-trie/trunk/hash-trie.egg
r38591 r38604 5 5 6 6 ((synopsis "hash-trie") 7 (version "1.1. 2")7 (version "1.1.3") 8 8 (category data) 9 9 (author "Taylor R. Campbell, [[kon lovett]] for CHICKEN") 10 10 (license "MIT") 11 (dependencies 12 (bitwise-utils "1.0.0")) 11 (dependencies) 13 12 (test-dependencies test) 14 13 (components 15 14 (extension hash-trie 16 15 (types-file) 17 (csc-options "-O3" "-d1" "-local" "- no-procedure-checks-for-toplevel-bindings") ) ) )16 (csc-options "-O3" "-d1" "-local" "-strict-types" "-no-procedure-checks-for-toplevel-bindings") ) ) ) -
release/5/hash-trie/trunk/hash-trie.scm
r38590 r38604 53 53 (import (chicken foreign)) 54 54 (import (chicken bitwise)) 55 (import (only bitwise-utils bitwise-count))56 55 57 56 ;; 57 58 ;w/ cplxnum since type cannot check value! 59 (define-type real (or integer float ratnum cplxnum)) 58 60 59 61 (define-type alist (list-of pair)) … … 94 96 (: string-hash (string -> fixnum)) 95 97 (: symbol-hash (symbol -> fixnum)) 96 (: exact-integer-hash ( fixnum-> fixnum))97 (: real-number-hash ( float-> fixnum))98 (: complex-number-hash ( cplxnum-> fixnum))98 (: exact-integer-hash (integer -> fixnum)) 99 (: real-number-hash (real -> fixnum)) 100 (: complex-number-hash (real -> fixnum)) 99 101 100 102 ;; 101 103 102 (define bit-count bitwise-count) 104 ;from srfi-60 example implementation - slib logical.scm 105 106 (define lognot bitwise-not) 107 108 ;@ 109 (define bitwise-bit-count 110 (letrec ((logcnt (lambda (n tot) 111 (if (zero? n) 112 tot 113 (logcnt (quotient n 16) 114 (+ (vector-ref 115 '#(0 1 1 2 1 2 2 3 1 2 2 3 2 3 3 4) 116 (modulo n 16)) 117 tot)))))) 118 (lambda (n) 119 (cond ((negative? n) (lognot (logcnt (lognot n) 0))) 120 ((positive? n) (logcnt n 0)) 121 (else 0))))) 122 ;@ 123 (define (logcount n) 124 (cond ((negative? n) (bitwise-bit-count (lognot n))) 125 (else (bitwise-bit-count n)))) 126 127 (define bit-count logcount) 128 103 129 (include "hash-trie.incl") 104 130
Note: See TracChangeset
for help on using the changeset viewer.