Changeset 22215 in project


Ignore:
Timestamp:
01/03/11 19:08:08 (9 years ago)
Author:
Christian Kellermann
Message:

isbn: refactor isbn10->isbn13 thanks to alaric

Location:
release/4/isbn/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/isbn/trunk/isbn.scm

    r22174 r22215  
    9696                  isbn))))
    9797   
    98    (define (isbn13->string isbn)
    99      (string-append
    100       (number->string (list-ref isbn 0))
    101       (number->string (list-ref isbn 1))
    102       (number->string (list-ref isbn 2))
    103       "-"
    104       (number->string (list-ref isbn 3))
    105       "-"
    106       (number->string (list-ref isbn 4))
    107       (number->string (list-ref isbn 5))
    108       (number->string (list-ref isbn 6))
    109       (number->string (list-ref isbn 7))
    110       (number->string (list-ref isbn 8))
    111       "-"
    112       (number->string (list-ref isbn 9))
    113       (number->string (list-ref isbn 10))
    114       (number->string (list-ref isbn 11))
    115       "-"
    116       (number->string
    117        (if (= (list-ref isbn 12) 10) 0
    118            (list-ref isbn 12)))))
    119 
    12098   (define (isbn10->isbn13 isbn10-string)
    12199     (and-let* ((isbn10 (string->isbn isbn10-string))
     
    127105                 (append isbn13-sans-checkdigit
    128106                         (list (isbn13-checkdigit isbn13-sans-checkdigit)))))
    129                (isbn13->string isbn13)))
     107               (isbn->string isbn13)))
    130108
    131109
  • release/4/isbn/trunk/tests/run.scm

    r22169 r22215  
    2929
    3030(test-group "ISBN upgrade"
    31             (test "normal isbn" "978-8-17525-766-5" (isbn10->isbn13 "817525766-0"))
    32             (test "isbn with X as check digit" "978-0-52103-311-4" (isbn10->isbn13 "052103311X")))
     31            (test "normal isbn" "9788175257665" (isbn10->isbn13 "817525766-0"))
     32            (test "isbn with X as check digit" "9780521033114" (isbn10->isbn13 "052103311X")))
    3333
    3434(test-group "normalize-isbn"
Note: See TracChangeset for help on using the changeset viewer.