Simple code snippet: fast all_equal/1 predicate #2971
hurufu
started this conversation in
Show and tell
Replies: 2 comments 4 replies
-
Shorter, faster, purer (NSTO):
|
Beta Was this translation helpful? Give feedback.
3 replies
-
I think it would be nice to create an online collection of Prolog idioms and small code snippets. Rosetta code isn't helpful, because all tasks there are biased towards imperative languages. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, haven't been active for a long time.
Recently I wrote very fast
all_equal/1
it outperforms naivemaplist(=(Element), List)
two times and reaches theoretical minimum number of inferences for such task. It uses cyclic terms – which you might strongly dislike, but they are good for performance.Here are some numbers:
Maybe someone can find it useful if you happen to need a lot of same elements :)
Beta Was this translation helpful? Give feedback.
All reactions