Skip to content

Commit

Permalink
Fixing rna-transcription to match readme.
Browse files Browse the repository at this point in the history
This fixes #3.

and fixes the lisp project specific problem mentioned in:
exercism/exercism#1310.
  • Loading branch information
verdammelt committed Aug 24, 2014
1 parent 04b0383 commit b7cad96
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
7 changes: 6 additions & 1 deletion rna-transcription/example.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
(coerce strand 'list))
(signal 'error)))

(defparameter dna->rna
'((#\C . #\G) (#\G . #\C) (#\A . #\U) (#\T . #\A)))

(defun to-rna (strand)
(validate-strand strand)
(substitute #\U #\T strand))
(concatenate 'string
(mapcar #'(lambda (c) (cdr (assoc c dna->rna)))
(coerce strand 'list))))
20 changes: 10 additions & 10 deletions rna-transcription/rna-transcription-test.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@

(in-package :rna-transcription-test)

(define-test transcribes-cytidine-unchanged
(assert-equal "C" (dna:to-rna "C")))
(define-test transcribes-cytidine-to-guanosine
(assert-equal "G" (dna:to-rna "C")))

(define-test transcribes-guanosine-unchanged
(assert-equal "G" (dna:to-rna "G")))
(define-test transcribes-guanosine-to-cytidine
(assert-equal "C" (dna:to-rna "G")))

(define-test transcribes-adenosine-unchanged
(assert-equal "A" (dna:to-rna "A")))
(define-test transcribes-adenosine-to-uracile
(assert-equal "U" (dna:to-rna "A")))

(define-test it-transcribes-thymidine-to-uracil
(assert-equal "U" (dna:to-rna "T")))
(define-test it-transcribes-thymidine-to-adenosine
(assert-equal "A" (dna:to-rna "T")))

(define-test it-transcribes-all-occurrences-of-thymidine-to-uracil
(assert-equal "ACGUGGUCUUAA" (dna:to-rna "ACGTGGTCTTAA")))
(define-test it-transcribes-all-nucleotides
(assert-equal "UGCACCAGAAUU" (dna:to-rna "ACGTGGTCTTAA")))

(define-test it-validates-dna-strands
(assert-error 'error (dna:to-rna "XCGFGGTDTTAA")))
Expand Down

0 comments on commit b7cad96

Please sign in to comment.