Loris  Check-in [50a6cdb35a]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use newly added make-chain-pred in constructing version comparisors
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:50a6cdb35a95b516c744317a1f876ac97e50876d
User & Date: jesper 2016-04-16 11:30:05
Context
2016-04-16
11:30
I guess these changes warrant another year on the (c) line. check-in: 832dae9274 user: jesper tags: trunk
11:30
Use newly added make-chain-pred in constructing version comparisors check-in: 50a6cdb35a user: jesper tags: trunk
11:27
Add procedure make-chain-pred, which makes procedures taking any number of arguments and compares them two-and-two, in the order given, with a supplied predicate. For example: (define string-or-number= (make-chain-pred (lambda (a b) (= (if (string? a) (string->number a) a) (if (string? b) (string->number b) b))))) (string-or-number= "50" 50 "000050.00") will now evaluate to #t. check-in: e839f3b951 user: jesper tags: trunk
Changes

Changes to version.scm.

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
..
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
(define-library (loris version)
  (import (scheme base)
          (scheme case-lambda)
          (loris convenience)
          (srfi 1)
          (srfi 13)
          (srfi 14))
  (export semantic full-semantic assert tokenise-semantic-version version-number< semantic-version<)
  (begin
    (define version (list 2 1 0	        ; version:      numeric (major, minor, patch)
                          "devel"       ; pre-release:  #f or alphanumeric string (no hyphens!)
                          #f))          ; metadata:     #f or alphanumeric string (no hyphens!)

    (define (tokenise-semantic-version v)
      (if (not v) '()
................................................................................
                  (b b-list))
        (cond ((null? b) #f)
              ((null? a) #t)
              ((version-number< (car a) (car b)) #t)
              ((version-number< (car b) (car a)) #f)
              (else (check (cdr a) (cdr b))))))

    (define (make-lesser-than is<)
      (lambda (num1 . more-nums)
        (let loop ((lesser num1)
                   (rest more-nums))
          (cond ((null? rest) #t)
                ((not (is< lesser (car rest))) #f)
                (else (loop (car rest) (cdr rest)))))))

    (define version-number< (make-lesser-than version-number</compare-two))
    (define semantic-version< (make-lesser-than semantic-version</compare-two))

    (define (compatible? wanted actual)
      ;; Unparse any prerelease tags present and append them to (list
      ;; MINOR PATCH).  We're not interested in the MAJOR version,
      ;; since checking for compatiblity simply means applying equal?
      ;; to them.
      (let ((wanted-tail (append (cdr (take wanted 3))







|







 







<
<
<
<
<
<
<
<
|
|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
..
68
69
70
71
72
73
74








75
76
77
78
79
80
81
82
83
(define-library (loris version)
  (import (scheme base)
          (scheme case-lambda)
          (loris convenience)
          (srfi 1)
          (srfi 13)
          (srfi 14))
  (export semantic full-semantic assert tokenise-semantic-version)
  (begin
    (define version (list 2 1 0	        ; version:      numeric (major, minor, patch)
                          "devel"       ; pre-release:  #f or alphanumeric string (no hyphens!)
                          #f))          ; metadata:     #f or alphanumeric string (no hyphens!)

    (define (tokenise-semantic-version v)
      (if (not v) '()
................................................................................
                  (b b-list))
        (cond ((null? b) #f)
              ((null? a) #t)
              ((version-number< (car a) (car b)) #t)
              ((version-number< (car b) (car a)) #f)
              (else (check (cdr a) (cdr b))))))









    (define version-number< (make-chain-pred version-number</compare-two))
    (define semantic-version< (make-chain-pred semantic-version</compare-two))

    (define (compatible? wanted actual)
      ;; Unparse any prerelease tags present and append them to (list
      ;; MINOR PATCH).  We're not interested in the MAJOR version,
      ;; since checking for compatiblity simply means applying equal?
      ;; to them.
      (let ((wanted-tail (append (cdr (take wanted 3))