Map function

Transcripción de ARN
Transcripción de ARN en Go
// Package strand is a small library for returning the RNA complement of a DNA strand.
package rnatranscription

import "strings"

// toRNA returns the RNA complement of the input DNA strand.
func ToRNA(dna string) string {
	return strings.Map(func(r rune) rune {
		switch r {
		case 'G':
			return 'C'
		case 'C':
			return 'G'
		case 'T':
			return 'A'
		case 'A':
			return 'U'
		}
		return r
	}, dna)
}

This approach passes the input string into the strings Map() function. The function uses a switch statement to translate the DNA character into an RNA character.

Translation missing: es-419.number.nth.ordinalized Sep 2026 · ¿Te resulta útil?