Hacker News new | ask | show | jobs
by chielk 3309 days ago
I simplified your notation a bit and added some slightly silly predicates, but this works:

    ticker('TimeWarner', 'TWC', date(1999-01-01), date(2014-04-31)).
    ticker('TimeWarner', 'AOL', date(2014-05-01), date(9999-01-01)).
    
    transform_date(date(Y-M-D), R) :-
        R is Y * 416 + M * 32 + D.

    after(Adate, Bdate) :-
        transform_date(Adate, A),
        transform_date(Bdate, B),
        A @> B.
    
    current_at(Name, C, Start, End, T) :-
        ticker(Name, C, Start, End),
        after(T, Start),
        after(End, T).



    ?- current_at('TimeWarner', C, S, E, date(2017-05-29)).
    C = 'AOL',
    S = date(2014-5-1),
    E = date(9999-1-1).
1 comments

Thanks - this is great. I stand corrected!