Sha256: 0e86c9ddcd028f65f9087cf7bd63597b557e25bcc822f2274a08eecbace6ca8b

Contents?: true

Size: 488 Bytes

Versions: 200

Compression:

Stored size: 488 Bytes

Contents

object RnaTranscription {
  private type Strand = String
  private type Nucleotide = Char

  def toRna(dna: Strand): Option[Strand] =
    dna.foldRight (Option("")) { case (char, rna) =>
      for {
        rnaNucleotide <- toRnaNucleotide(char)
        rnaStrand <- rna
      } yield rnaNucleotide +: rnaStrand
  }

  private val DnaToRna =
    Map('G' -> 'C', 'C' -> 'G', 'T' -> 'A', 'A' -> 'U')

  private def toRnaNucleotide(char: Char): Option[Nucleotide] =
     DnaToRna get char
}

Version data entries

200 entries across 200 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.179 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.178 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.177 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.176 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.175 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.174 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.173 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.172 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.171 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.170 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.169 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.167 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.166 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.165 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.164 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.163 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.162 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.161 tracks/scala/exercises/rna-transcription/example.scala
trackler-2.2.1.160 tracks/scala/exercises/rna-transcription/example.scala