3 ms·
I've identified many cases in my employer's codebase that are something like: items = fetch_list_from_db() for item in items: if item.match(param
by tlack 5y ago
I've identified many cases in my employer's codebase that are something like:
items = fetch_list_from_db()
for item in items:
if item.match(param):
..
elif item.whatever > param2 || item.override:
..
else:
some_default_behavior()
return custom_sort_thing(results)
In each instance, the logic is critical to business function and frequently evolving, but often underspecified, hard to audit, and each case has its own little missing features.
Prolog allows me to very easily state these rules in a way others can understand at a glance and keep them separate from the operational code. Best of it all, it solves for all possible answers (or all inputs for a given answer) without implicitly stating very much looping or recursion - even less so than functional languages in some cases.