0
votes

How to write a function in OCaml, that accepts two lists and returns the Boolean value "true", if the two input lists are anagrams.

I'm pretty new to OCaml and I would love to learn more.

The compiler would then tell me something like this, after I'd evaluate the code:

# anagram ([1;2;4;7] , [2;4;7;9]) ;;
- : bool = false
1

1 Answers

5
votes

One way to solve this problem would be based on the observation that two lists are anagrams if and only if they are the same when sorted.