mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
766 B
45 lines
766 B
6 years ago
|
# join
|
||
|
## Instructions
|
||
|
|
||
|
Write a function, Join, that returns the elements of a slice strings (arstr) join together in one string. Using the string 'sep' as a separator between each element of the array
|
||
|
|
||
|
The function must have the next signature.
|
||
|
|
||
|
## Expected function
|
||
|
|
||
|
```go
|
||
|
|
||
|
func Join(arstr []string, sep string) string {
|
||
|
|
||
|
}
|
||
|
|
||
|
```
|
||
|
|
||
|
## Usage
|
||
|
|
||
|
Here is a possible [program](TODO-LINK) to test your function :
|
||
|
|
||
|
```go
|
||
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
student ".."
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
arrStr := []string{"hello", "how", "are", "you"}
|
||
|
joined := student.Join(arrStr, "--")
|
||
|
fmt.Println(joined)
|
||
|
}
|
||
|
```
|
||
|
|
||
|
And its output :
|
||
|
|
||
|
```console
|
||
|
student@ubuntu:~/student/join$ go build
|
||
|
student@ubuntu:~/student/join$ ./join
|
||
|
hello--how--are--you
|
||
|
student@ubuntu:~/student/join$
|
||
|
```
|