Sha256: 6a07927e148d3ad5e04cf9f09dd1b01c31e00a434a4ade287fb9534b0b50ac75

Contents?: true

Size: 737 Bytes

Versions: 330

Compression:

Stored size: 737 Bytes

Contents

module NucleotideCount exposing (..)

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

330 entries across 330 versions & 1 rubygems

Version Path
trackler-2.2.1.113 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.111 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.110 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.109 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.108 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.107 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.106 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.105 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.104 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.103 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.102 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.101 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.100 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.99 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.98 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.97 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.96 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.95 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.94 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm
trackler-2.2.1.93 tracks/elm/exercises/nucleotide-count/NucleotideCount.example.elm