Hash :
18f406af
Author :
Thomas de Grivel
Date :
2023-07-11T13:20:42
(compare 'a 'b)
=> -1
(compare 'a "a")
=> -1
(compare '(a b 1) '(a b 2))
=> -1
(defstruct fruit weight price)
(defmethod compare ((a fruit) (b fruit))
(compare (* (fruit-price a) (fruit-weight a))
(* (fruit-price b) (fruit-weight b))))
(let ((apple (make-fruit :price 0.3 :weight 100))
(orange (make-fruit :price 4.5 :weight 1000)))
(compare apple orange))
=> -1
This project welcomes COMPARE methods for types that have an atomic type specifier, with an emphasis on speed and functional correctness.
To submit contributions, just fork the project and submit a pull request.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
cl-compare
==========
Compare anything
----------------
```common-lisp
(compare 'a 'b)
=> -1
(compare 'a "a")
=> -1
(compare '(a b 1) '(a b 2))
=> -1
```
---
Your own order
--------------
```common-lisp
(defstruct fruit weight price)
(defmethod compare ((a fruit) (b fruit))
(compare (* (fruit-price a) (fruit-weight a))
(* (fruit-price b) (fruit-weight b))))
(let ((apple (make-fruit :price 0.3 :weight 100))
(orange (make-fruit :price 4.5 :weight 1000)))
(compare apple orange))
=> -1
```
---
Contribute
----------
This project welcomes COMPARE methods for types that have an
[atomic type specifier][1], with an emphasis on speed and functional
correctness.
[1]: http://www.lispworks.com/documentation/lw51/CLHS/Body/04_bc.htm
To submit contributions, just fork the project and submit a pull
request.