Quantcast
Channel: Active questions tagged ocaml - Stack Overflow
Viewing all articles
Browse latest Browse all 527

Checking if all elements are equal with map/fold

$
0
0

Given a list of elements, like [1, 1, 1] or ["a", "a", "a"], how can I check if they're all equal using map/fold?

I tried to do something like this:

let eq lst = fold (=) lst

which doesn't compile because there's no accumulator, but I'm really not so sure what to put for the accumulator. Any help is appreciated.


Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>