AllSameBy
Examples
open all close allBasic Examples (2)
Scope (1)
Applications (1)
Properties & Relations (1)
AllSameBy can be implemented by applying f to all elements and then checking whether the results are all the same:
list = {-5, 5, 5, 3 + 4I, -3 - 4I, 4, -4 + 3I, 5I, -5, 5};
Apply[SameQ][Map[Abs][list]]AllSameBy[list, Abs]The difference becomes apparent when there are side effects.
AllSameBy will cease evaluation if any variation in f[en] is found:
AllSameBy[list, Echo /* Abs]Whereas Map would evaluate on all elements prior to checking SameQ:
list = {-5, 5, 5, 3 + 4I, -3 - 4I, 4, -4 + 3I, 5I, -5, 5};
Apply[SameQ][Map[Echo /* Abs][list]]History
Text
Wolfram Research (2024), AllSameBy, Wolfram Language function, https://reference.wolfram.com/language/ref/AllSameBy.html.
CMS
Wolfram Language. 2024. "AllSameBy." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/AllSameBy.html.
APA
Wolfram Language. (2024). AllSameBy. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AllSameBy.html
BibTeX
@misc{reference.wolfram_2026_allsameby, author="Wolfram Research", title="{AllSameBy}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/AllSameBy.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_allsameby, organization={Wolfram Research}, title={AllSameBy}, year={2024}, url={https://reference.wolfram.com/language/ref/AllSameBy.html}, note=[Accessed: 12-June-2026]}