Skip to content

Commit

Permalink
Add comments to example solution
Browse files Browse the repository at this point in the history
  • Loading branch information
keiravillekode committed Dec 23, 2023
1 parent 4a63587 commit d38ccd9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions exercises/practice/isogram/.meta/example.sml
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
val isIsogram: string -> bool =
let
val a = Char.ord #"a"

(* We represent each letter by setting a different bit,
* for example the letter c is encoded as ...00100 binary.
*)
fun letterValue (c: char): word =
Word.<<(0wx1, Word.fromInt(Char.ord (Char.toLower c) - a))

(* seen represents the set of letters that have been seen
* so far. For example, if we have seen the letters d and c,
* this is encoded as ...01100 binary.
* If we find a letter in l that matches a letter already
* seen, we return false.
*)
fun recurse (seen: word) (l: char list): bool =
case l of
nil => true
Expand Down

0 comments on commit d38ccd9

Please sign in to comment.