MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / Reverse

Function Reverse

conversion/decimaltobinary.go:24–30  ·  view source on GitHub ↗

Reverse() function that will take string, and returns the reverse of that string.

(str string)

Source from the content-addressed store, hash-verified

22// Reverse() function that will take string,
23// and returns the reverse of that string.
24func Reverse(str string) string {
25 rStr := []rune(str)
26 for i, j := 0, len(rStr)-1; i < len(rStr)/2; i, j = i+1, j-1 {
27 rStr[i], rStr[j] = rStr[j], rStr[i]
28 }
29 return string(rStr)
30}
31
32// DecimalToBinary() function that will take Decimal number as int,
33// and return its Binary equivalent as a string.

Callers 1

DecimalToBinaryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected