2 ms·
The difference between your Erlang example and Prolog is that Prolog "throws away" computation. The whole predicate has to match, not just the first pattern. Th
by bjourne 8y ago
The difference between your Erlang example and Prolog is that Prolog "throws away" computation. The whole predicate has to match, not just the first pattern. This difference leads to very hard to predict control flow.
- derefr 8y agoTheoretically, Erlang does this as well; it just restricts the set of functions you can use in a clause-head to a language-defined set† of pure (and almost entirely O(1)‡) functions, such that you don't really worry about how much or little computation is going on during clause-head unification. † https://learnyousomeerlang.com/syntax-in-functions#guards-guards https://learnyousomeerlang.com/syntax-in-functions#guards-gu... ‡ `length(List)` is allowed in guards and is O(N), though it could be O(1) in a different VM implementation that makes different trade-offs.