This is good. I adapted it to Haskell, recording letter frequencies in Maps/dictionaries. The Map data structure is already an instance of the Eq typeclass, so it was a one-liner to add the equality check:
importqualifiedData.Map.StrictasM-- incrementor for Map entries (used by Map's alter function)incNothing=Just1inc(Justx)=Just(x+1)-- produces a Map containing frequencies of elements in a given list (or Foldable)-- e.g. a Map of frequencies of characters in a given wordfrequencies::(Foldablet,Ordk,Numa)=>tk->M.Mapkafrequencies=foldr(M.alterinc)M.empty-- equality is already defined for Maps :)isAnagramword1word2=frequenciesword1==frequenciesword2
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is good. I adapted it to Haskell, recording letter frequencies in Maps/dictionaries. The Map data structure is already an instance of the Eq typeclass, so it was a one-liner to add the equality check: