Browse Source

Update sliceprog.en.md

pull/510/head
Christopher Fremond 5 years ago committed by GitHub
parent
commit
91fdaaa4bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      subjects/sliceprog.en.md

14
subjects/sliceprog.en.md

@ -13,9 +13,9 @@ This means that:
### Instructions
Write a **program** that replicates the javascript function `slice`.
Write a **function** that replicates the javascript function `slice`.
The program receives an array of strings and one or more integers, and returns an array of strings. The returned array is part of the received one but cut from the position indicated in the first int, until the position indicated by the second int.
The function receives an array of strings and one or more integers, and returns an array of strings. The returned array is part of the received one but cut from the position indicated in the first int, until the position indicated by the second int.
In case there only exists one int, the resulting array begins in the position indicated by the int and ends at the end of the received array.
@ -41,11 +41,11 @@ import "fmt"
func main(){
arr := []string{"coding", "algorithm", "ascii", "package", "golang"}
fmt.Println(arr, 1)
fmt.Println(arr, 2, 4)
fmt.Println(arr, -3)
fmt.Println(arr, -2, -1)
fmt.Println(arr, 2, 0)
fmt.Println(Slice(arr, 1))
fmt.Println(Slice(arr, 2, 4))
fmt.Println(Slice(arr, -3))
fmt.Println(Slice(arr, -2, -1))
fmt.Println(Slice(arr, 2, 0))
}
```

Loading…
Cancel
Save