Sha256: 75d39035d92aaa1a6bfab2db1d5f1347de0ad4b10ec273ced510f7ef6f608218
Contents?: true
Size: 708 Bytes
Versions: 118
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
118 entries across 118 versions & 1 rubygems