src/rna_transcription.clj

1
2
3
4
5
6
7
8
9
10
11
12
(ns rna-transcription
  (:require [clojure.string :as string]))

(def nucleotide-mapping
  {"A" "U"
   "T" "A"
   "C" "G"
   "G" "C"})

(defn to-rna [dna]
  {:pre [(re-matches #"[ACGT]*" dna)]}
  (string/replace dna #"[ACGT]" nucleotide-mapping))

Comments

Using a precondition to tidy things up a bit.

helenst commented 29 March 2016 at 07:24 UTC

You're not logged in right now. Please login via GitHub to comment