Reverse() function that will take string, and returns the reverse of that string.
(str string)
| 22 | // Reverse() function that will take string, |
| 23 | // and returns the reverse of that string. |
| 24 | func 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. |