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.139 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.138 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.137 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.136 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.135 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.134 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.133 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.132 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.131 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.130 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.129 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.128 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.127 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.126 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.125 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.124 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.123 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.122 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.121 tracks/fsharp/exercises/nucleotide-count/Example.fs
trackler-2.2.1.120 tracks/fsharp/exercises/nucleotide-count/Example.fs