Skip to content

Instantly share code, notes, and snippets.

@cddr
Created September 20, 2010 20:45
Show Gist options
  • Save cddr/588619 to your computer and use it in GitHub Desktop.
Save cddr/588619 to your computer and use it in GitHub Desktop.
(defun rangecheck (rc)
(lambda (actual)
(let* ((comparator (intern (property rc "Comparator") #.*package*))
(unit (find-def (kid-like 'measurementunitref :in rc)))
(test (case comparator
(LT '<)
(LE '<=)
(GT '>)
(GE '>=)
(EQ '=)
(IN 'member)
(NOTIN (complement #'member))))
(vals (if (member comparator '(IN NOTIN))
(mapcar (lambda (val)
(read-from-string (value-of val)))
(kids-like 'checkvalue :in rc))
(read-from-string (value-of (kid-like 'checkvalue :in rc)))))
(values
(funcall test actual vals)
(string-trim +whitespace+ (value-of (kid-like 'errormessage :in rc)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment