diff --git a/subjects/swapfirst/README.md b/subjects/swapfirst/README.md index 87b09ad6f..3c7719d3a 100644 --- a/subjects/swapfirst/README.md +++ b/subjects/swapfirst/README.md @@ -1,8 +1,9 @@ -## swap-first +## swapfirst ### Instructions -- Write a function that takes a slice in parameter and swaps the two first element then return the new value +Write a function that takes a slice of integers as an argument and returns another slice of integers with the two first elements swapped. + - If the slice contains less than two elements return the same slice. ### Expected function @@ -15,27 +16,28 @@ func SwapFirst(slice []int) []int { ### Usage -Here is a possible program to test your function : +Here is a possible program to test your function: ```go package main import ( "fmt" + "piscine" ) func main() { - fmt.Println(SwapFirst([]int{1,2,3,4})) - fmt.Println(SwapFirst([]int{3,4})) - fmt.Println(SwapFirst([]int{1})) + fmt.Println(piscine.SwapFirst([]int{1, 2, 3, 4})) + fmt.Println(piscine.SwapFirst([]int{3, 4, 6})) + fmt.Println(piscine.SwapFirst([]int{1})) } ``` -And its output : +And its output: ```console $ go run . -[2,1,3,4] -[4,3] +[2 1 3 4] +[4 3 6] [1] ```