#| http://data.bls.gov/cgi-bin/cpicalc.pl?year1=1980&cost1=1.24&year2=2007 => ... $3.12
|# (defun get-answer (cost1 year1 year2) (ap5::wget (format nil "http://data.bls.gov/cgi-bin/cpicalc.pl?year1=~a&cost1=~a&year2=~a" year1 cost1 year2) "inflation.txt") (with-open-file (f "inflation.txt") (loop while (setf line (read-line f nil nil)) do (when (search "$" line :test 'string-equal) (let* ((dollar (position #\$ line)) (lt (position #\< line :start dollar)) (ans (read-from-string line nil nil :start (1+ dollar) :end lt))) (return-from get-answer ans)))))) (defrelation inflation :derivation individual-derived :documentation "(x y z) s.t. $1 in year x is worth $z in year y" :arity 3 :types (integer integer number) :equivs (= = =) :nonatomic t :type-enforcements (:none) :size ((input input output) 1) :tester (lambda (&rest ignore) (declare (ignore ignore)) '(lambda (rel x y z) (and (integerp x)(integerp y) (numberp z) (ap5::loop for ans s.t. (inflation x y ans) thereis (= ans z))))) :generator ((simplegenerator (y1 y2 output) (and (integerp y1)(integerp y2) (ignore-errors (get-answer 1 y1 y2))) 1e6)))