2019-04-24 17:17:07 +00:00
|
|
|
## strrev
|
2019-04-24 17:06:54 +00:00
|
|
|
|
2019-04-24 17:17:07 +00:00
|
|
|
### Instructions
|
2019-04-24 17:06:54 +00:00
|
|
|
|
2020-02-25 12:02:16 +00:00
|
|
|
- Write a function that reverses a `string`.
|
2019-04-24 17:06:54 +00:00
|
|
|
|
2021-06-02 16:33:44 +00:00
|
|
|
- This function will **return** the reversed `string`.
|
2019-04-24 17:06:54 +00:00
|
|
|
|
2019-04-24 17:17:07 +00:00
|
|
|
### Expected function
|
2019-04-24 17:06:54 +00:00
|
|
|
|
|
|
|
```go
|
|
|
|
func StrRev(s string) string {
|
|
|
|
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-04-24 17:17:07 +00:00
|
|
|
### Usage
|
2019-04-24 17:06:54 +00:00
|
|
|
|
2020-02-25 12:02:16 +00:00
|
|
|
Here is a possible program to test your function :
|
2019-04-24 17:06:54 +00:00
|
|
|
|
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2021-05-02 15:18:17 +00:00
|
|
|
"piscine"
|
2019-04-24 17:06:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
s := "Hello World!"
|
|
|
|
s = piscine.StrRev(s)
|
|
|
|
fmt.Println(s)
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
And its output :
|
|
|
|
|
|
|
|
```console
|
2021-04-28 09:47:34 +00:00
|
|
|
$ go run .
|
2019-04-24 17:06:54 +00:00
|
|
|
!dlroW olleH
|
2021-04-28 09:47:34 +00:00
|
|
|
$
|
2019-04-24 17:06:54 +00:00
|
|
|
```
|