Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Polymorphic Code Substitution #13

Open
normanhh3 opened this issue Feb 5, 2022 · 0 comments
Open

Implement Polymorphic Code Substitution #13

normanhh3 opened this issue Feb 5, 2022 · 0 comments

Comments

@normanhh3
Copy link
Owner

In tests/Tests.fs there is a note about why we have code duplication. Need to follow-up with the linked thread and find out if there is a way around this situation through polymorphic record access.

// NOTE: The following two method implementations exist because I can't polymorphically access the Word field
// of two different record types in F#
// See: https://fslang.uservoice.com/forums/245727-f-language/suggestions/9633858-structural-extensible-records-like-elm-concrete

let getUniqueCharsFromInputWords (wl:InputWords) =
new String(
wl
|> Seq.map (fun w -> w.Word.ToLowerInvariant())
|> Seq.collect (fun ltrs -> ltrs.ToCharArray())
|> Seq.sort
|> Seq.toArray)

let getUniqueCharsFromPuzzleWords (pw:PuzzleWords) =
new String(
pw
|> Seq.map (fun w -> w.Word.ToLowerInvariant())
|> Seq.collect (fun ltrs -> ltrs.ToCharArray())
|> Seq.sort
|> Seq.toArray)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant