Sha256: 661786840a9c13023ca0a7020cc0c9ab61b61d6b246225bd6ece33ae6e5c10fb
Contents?: true
Size: 708 Bytes
Versions: 70
Compression:
Stored size: 708 Bytes
Contents
enum TranscriptionError: Error { case invalidNucleotide } struct Nucleotide { func complementOfDNA() throws -> String { return try transcribe(dnaToRna) } private let value: String init(_ nucleotide: String) { self.value = nucleotide } private let dnaToRna: [Character:String] = [ "G": "C", "C": "G", "T": "A", "A": "U" ] private func transcribe(_ dict: [Character : String]) throws -> String { var tempText = "" for each in self.value.characters { if dict[each] == nil { throw TranscriptionError.invalidNucleotide } tempText += dict[each] ?? "" } return tempText } }
Version data entries
70 entries across 70 versions & 1 rubygems