Created
August 4, 2023 02:20
-
-
Save er2/e086c09538ee75212ee1107c865e24db to your computer and use it in GitHub Desktop.
Scala 3 anagram detector: https://buttondown.email/cassidoo/archive/science-is-organized-knowledge-wisdom-is/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isAnagram(s1: String, s2: String): Boolean = | |
(s1 diff s2).isEmpty | |
isAnagram("barbie", "oppenheimer").ensuring(_ == false) | |
isAnagram("race", "care").ensuring(_ == true) | |
isAnagram("tree", "tere").ensuring(_ == true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment