diff options
Diffstat (limited to 'pl')
-rw-r--r-- | pl/track_episodes.pl | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/pl/track_episodes.pl b/pl/track_episodes.pl index f18e85c..1973a75 100644 --- a/pl/track_episodes.pl +++ b/pl/track_episodes.pl @@ -2,7 +2,9 @@ toggle_episode/1, forget_episode/1, most_recently_watched/1, - watched/1]). + watched/1, + next_unwatched/2, + previous_unwatched/2]). :- use_module(library(dcg/basics)). :- use_module(library(registry)). @@ -94,3 +96,17 @@ most_recently_watched(Ep) :- watched(Ep) :- episode_watched(Ep, true). + +next_unwatched(Ep0, Ep) :- + Ep1 is Ep0 + 1, + ( \+ watched(Ep1) + -> Ep = Ep1 + ; next_unwatched(Ep1, Ep) + ). + +previous_unwatched(Ep0, Ep) :- + Ep1 is Ep0 - 1, + ( \+ watched(Ep1) + -> Ep = Ep1 + ; previous_unwatched(Ep1, Ep) + ). |