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.
 
 
 
 
 
 

696 B

compact

Instructions

Écrire une fonction Compact qui prend un pointeur sur tableau comme paramètre et qui réécris sur les éléments qui pointent sur nil.

  • Indice : Cette fonction existe in Ruby.

Fonction attendue

func Compact(ptr *[]string, length int) int {

}

Utilisation

Voici un éventuel programme pour tester votre fonction :

package main

import fmt

func main() {
	array := []string{"hello", " ", "there", " ", "bye"}

	ptr := &array
	fmt.Println(Compact(ptr, len(array)))
}

Et son résultat :

student@ubuntu:~/piscine/test$ go build
student@ubuntu:~/piscine/test$ ./test
3
student@ubuntu:~/piscine/test$