Changeset 14801 in project for chicken


Ignore:
Timestamp:
05/27/09 00:42:54 (10 years ago)
Author:
felix winkelmann
Message:

string-hash[-ci] redundancy slightly improved

Location:
chicken/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/manual/Unit srfi-13

    r13683 r14801  
    1414</enscript>
    1515
     16The {{string-hash}} and {{string-hash-ci}} procedures are
     17not provided in this library unit, [[Unit srfi-69]] has
     18compatible definitions.
     19
     20
    1621---
    1722Previous: [[Unit srfi-4]]
  • chicken/trunk/manual/Unit srfi-69

    r13740 r14801  
    317317==== string-hash
    318318
    319  [procedure] (string-hash STRING [BOUND])
     319 [procedure] (string-hash STRING [BOUND START END])
    320320
    321321For use with {{string=?}} as a {{hash-table-equivalence-function}}.
     322The optional {{START}} and {{END}} arguments may be given to limit
     323the hash calculation to a specific sub-section of {{STRING}}.
    322324
    323325
    324326==== string-ci-hash
    325327
    326  [procedure] (string-ci-hash STRING [BOUND])
     328 [procedure] (string-hash-ci STRING [BOUND START END])
     329 [procedure] (string-ci-hash STRING [BOUND START END])
    327330
    328331For use with {{string-ci=?}} as a {{hash-table-equivalence-function}}.
  • chicken/trunk/srfi-13.import.scm

    r12937 r14801  
    6262   string-for-each
    6363   string-for-each-index
    64    string-hash
    65    string-hash-ci
    6664   string-index
    6765   string-index-right
  • chicken/trunk/srfi-69.import.scm

    r12937 r14801  
    6666   number-hash
    6767   object-uid-hash
     68   string-hash-ci
    6869   string-ci-hash
    6970   string-hash
  • chicken/trunk/srfi-69.scm

    r14527 r14801  
    359359;; String Hash:
    360360
    361 (define (string-hash str #!optional (bound hash-default-bound))
     361(define (string-hash str #!optional (bound hash-default-bound) . start+end)
    362362  (##sys#check-string str 'string-hash)
    363363  (##sys#check-exact bound 'string-hash)
    364   (%hash/limit (%string-hash str) bound) )
    365 
    366 (define (string-ci-hash str #!optional (bound hash-default-bound))
     364  (let ((str (if (pair? start+end)
     365                 (let-optionals start+end ((start 0)
     366                                           (end (##sys#size str)))
     367                   (##sys#check-range start 0 (##sys#size str) 'string-hash)
     368                   (##sys#check-range end 0 (##sys#size str) 'string-hash)
     369                   (##sys#substring str start end) )
     370                 str) ) )
     371    (%hash/limit (%string-hash str) bound) ) )
     372
     373(define (string-ci-hash str #!optional (bound hash-default-bound) . start+end)
    367374  (##sys#check-string str 'string-ci-hash)
    368375  (##sys#check-exact bound 'string-ci-hash)
     376  (let ((str (if (pair? start+end)
     377                 (let-optionals start+end ((start 0)
     378                                           (end (##sys#size str)))
     379                   (##sys#check-range start 0 (##sys#size str) 'string-hash-ci)
     380                   (##sys#check-range end 0 (##sys#size str) 'string-hash-ci)
     381                   (##sys#substring str start end) )
     382                 str) ) )
    369383  (%hash/limit (%string-ci-hash str) bound) )
     384
     385(define string-hash-ci string-ci-hash)
    370386
    371387
     
    458474                             (eq? string=? test))         string-hash]
    459475                        [(or (eq? core-string-ci=? test)
    460                              (eq? string-ci=? test))      string-ci-hash]
     476                             (eq? string-ci=? test))      string-hash-ci]
    461477                        [(or (eq? core= test)
    462478                             (eq? = test))                number-hash]
Note: See TracChangeset for help on using the changeset viewer.