#166
Comparisons
 

Difficulty:Easy
Topics:


For any orderable data type it's possible to derive all of the basic comparison operations (<, ≤, =, ≠, ≥, and >) from a single operation (any operator but = or ≠ will work). Write a function that takes three arguments, a less than operator for the data and two items to compare. The function should return a keyword describing the relationship between the two items. The keywords for the relationship between x and y are as follows: x = y → :eq x > y → :gt x < y → :lt
test not run
(= :gt (__ < 5 1))
test not run
(= :eq (__ (fn [x y] (< (count x) (count y))) "pear" "plum"))
test not run
(= :lt (__ (fn [x y] (< (mod x 5) (mod y 5))) 21 3))
test not run
(= :gt (__ > 0 2))


Code which fills in the blank: