Sha256: dc398c938be5272d9a966478bf66d413efbf40d8d65e1eb0c7f5170f3bd37502

Contents?: true

Size: 760 Bytes

Versions: 66

Compression:

Stored size: 760 Bytes

Contents

module NucleotideCount exposing (nucleotideCounts, version)

import String


version : Int
version =
    2


type alias NucleotideCounts =
    { a : Int
    , t : Int
    , c : Int
    , g : Int
    }


init : NucleotideCounts
init =
    { a = 0
    , t = 0
    , c = 0
    , g = 0
    }


update : Char -> NucleotideCounts -> NucleotideCounts
update char counts =
    case char of
        'A' ->
            { counts | a = counts.a + 1 }

        'T' ->
            { counts | t = counts.t + 1 }

        'C' ->
            { counts | c = counts.c + 1 }

        'G' ->
            { counts | g = counts.g + 1 }

        _ ->
            counts


nucleotideCounts : String -> NucleotideCounts
nucleotideCounts sequence =
    String.foldl update init sequence

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.179 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.178 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.177 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.176 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.175 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.174 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.173 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.172 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.171 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.170 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.169 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.167 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.166 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.165 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.164 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.163 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.162 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.161 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.160 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm