Skip to content

Implement Polymorphic Code Substitution #13

@normanhh3

Description

@normanhh3

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions