Changeset 38604 in project for release


Ignore:
Timestamp:
04/08/20 20:18:08 (4 months ago)
Author:
Kon Lovett
Message:

remove bitwise-utils dependency, strict types, fix real-number-hash & complex-number-hash type

Location:
release/5/hash-trie/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/5/hash-trie/trunk/hash-trie.egg

    r38591 r38604  
    55
    66((synopsis "hash-trie")
    7  (version "1.1.2")
     7 (version "1.1.3")
    88 (category data)
    99 (author "Taylor R. Campbell, [[kon lovett]] for CHICKEN")
    1010 (license "MIT")
    11  (dependencies
    12   (bitwise-utils "1.0.0"))
     11 (dependencies)
    1312 (test-dependencies test)
    1413 (components
    1514  (extension hash-trie
    1615    (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  
    5353(import (chicken foreign))
    5454(import (chicken bitwise))
    55 (import (only bitwise-utils bitwise-count))
    5655
    5756;;
     57
     58;w/ cplxnum since type cannot check value!
     59(define-type real (or integer float ratnum cplxnum))
    5860
    5961(define-type alist (list-of pair))
     
    9496(: string-hash (string -> fixnum))
    9597(: 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))
    99101
    100102;;
    101103
    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
    103129(include "hash-trie.incl")
    104130
Note: See TracChangeset for help on using the changeset viewer.