Map function

RNA ট্রান্সক্রিপশন
RNA ট্রান্সক্রিপশন 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.

23 সেপ্টেম্বর 2026 · কাজে লেগেছে?

Go ট্র্যাকে RNA ট্রান্সক্রিপশন অনুশীলনীর অন্য অ্যাপ্রোচগুলো

এই অনুশীলনীটি আমাদের কমিউনিটি যেভাবে অন্য ভাবেও সমাধান করেছে