Eclatement

Julia

function eclatement_1(ensemble,valeur)
   ensemble_1 = Structure(ensemble)
   ensemble_2 = Structure(ensemble)
   for element in Elements(ensemble)
      if element < valeur 
         Ranger_Element(ensemble_1,element)
      else
         Ranger_Element(ensemble_2,element)
      end
   end
   return (ensemble_1,ensemble_2)
end
function eclatement_2(ensemble)
   ensemble_1 = Structure(ensemble)
   ensemble_2 = Structure(ensemble)
   Initialiser(ensemble)
   while Enumeration(ensemble)
      element = Element_Courant(ensemble)
      if Pair(element)
         Ranger_Element(ensemble_1,element)
      else
         Ranger_Element(ensemble_2,element)
      end
      Element_Suivant(ensemble)
   end
   return (ensemble_1,ensemble_2)
end
function eclatement_3(ensemble)
   ensemble_1 = Structure(ensemble)
   ensemble_2 = Structure(ensemble)
   for element in Elements(ensemble)
      if Pair(element)
         Ranger_Element(ensemble_1,element)
      else
         Ranger_Element(ensemble_2,element)
      end
   end
   return (ensemble_1,ensemble_2)
end

Test

println("")
nombres = File(1,3,5,7,4,5,6)
Lister(nombres)

println("Eclatement Inférieur Supérieur à 6 ")
(e1,e2) = eclatement_1(nombres, 6)
println("Inferieur")
Lister(e1)
println("Superieur")
Lister(e2)

println("Eclatement PairImpair 1")
(e1,e2) = eclatement_2(nombres)
println("Pair")
Lister(e1)
println("Impair")
Lister(e2)

println("Eclatement PairImpair 2")
(e1,e2) = eclatement_3(nombres)
println("Pair")
Lister(e1)
println("Impair")
Lister(e2)

Swift

func eclatement_1 
   <_Element>(_ ensemble: Ensemble<_Element>
   ,_ valeur: _Element) 
   -> (e1: Ensemble<_Element>,e2: Ensemble<_Element>) {

   let ensemble_1 = Structure(ensemble)
   let ensemble_2 = Structure(ensemble)
   for element in ensemble {
      if element < valeur {
         Ranger_Element(ensemble_1,element)
      } else {
         Ranger_Element(ensemble_2,element)
      }
   }
   return (ensemble_1,ensemble_2)
}
func eclatement_2 
   <_Element>(_ ensemble: Ensemble<_Element>) 
   -> (e1: Ensemble<_Element>,e2: Ensemble<_Element>) {

   let ensemble_1 = Structure(ensemble)
   let ensemble_2 = Structure(ensemble)
   Initialiser(ensemble)
   while Enumeration(ensemble) {
      let element = Element_Courant(ensemble)
      if Pair(element) {
         Ranger_Element(ensemble_1,element)
      } else {
         Ranger_Element(ensemble_2,element)
      }
      Element_Suivant(ensemble)
   }
   return (ensemble_1,ensemble_2)
}
func eclatement_3 
   <_Element>(_ ensemble: Ensemble<_Element>) 
   -> (e1: Ensemble<_Element>,e2: Ensemble<_Element>) {

   let ensemble_1 = Structure(ensemble)
   let ensemble_2 = Structure(ensemble)
   for element in ensemble {
      if Pair(element) {
         Ranger_Element(ensemble_1,element)
      } else {
         Ranger_Element(ensemble_2,element)
      }
   }
   return (ensemble_1,ensemble_2)
}

 

copyright A rchitectures A pplicatives A vancées A3-Soft