Skip to content

Instantly share code, notes, and snippets.

@DonaldKellett
Created December 22, 2018 16:51
Show Gist options
  • Save DonaldKellett/143b4a66ff2a1c707891d417a7008aa0 to your computer and use it in GitHub Desktop.
Save DonaldKellett/143b4a66ff2a1c707891d417a7008aa0 to your computer and use it in GitHub Desktop.
Learn Prolog Now! - Chapter 5 - Practical Session - Programming Exercise 1 - Minimum of a list using tail recursion
accMin([H | T], A, Result) :- H < A, accMin(T, H, Result).
accMin([H | T], A, Result) :- H >= A, accMin(T, A, Result).
accMin([], A, A).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment