Sha256: 54cdcbde89078a0aef6295160f87c49bfd268c7c5b606dc6d399d7255c3c2509

Contents?: true

Size: 604 Bytes

Versions: 123

Compression:

Stored size: 604 Bytes

Contents

module NucleotideCount

let private validNucleotides = ['A'; 'T'; 'C'; 'G']

let private isValid nucleotide = List.contains nucleotide validNucleotides

let count (nucleotide:char) (strand:string) = 
    match isValid nucleotide with
    | true  -> Seq.fold (fun acc elem -> if elem = nucleotide then acc + 1 else acc) 0 strand
    | false -> failwith "Invalid nucleotide"

let nucleotideCounts strand = 
    if String.forall isValid strand then
        List.map (fun nucleotide -> (nucleotide, count nucleotide strand)) validNucleotides 
        |> Map.ofSeq
        |> Some
    else    
        None

Version data entries

123 entries across 123 versions & 1 rubygems

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