Skip to content
Snippets Groups Projects
Commit f6c978f2 authored by Gabrielle Van De Vijver's avatar Gabrielle Van De Vijver
Browse files

TieBreakFactory fonctionnelle sans gestion d'erreur

parent dc06d7cf
No related branches found
No related tags found
1 merge request!1Gabrielle
package comsoc
import("fmt")
func TieBreakFactory(orderedAlts []Alternative) (func ([]Alternative) (Alternative, error)){
return func (bestAlts []Alternative) (Alternative, error) {
bestAlt := bestAlts[0]
for _,alt:= range bestAlts[1:]{
if isPref(alt,bestAlt,orderedAlts){
bestAlt = alt
}
}
return bestAlt, nil
}
}
func Test_tieBreakFactory(){
orderedAlts := []Alternative{8,9,6,1,3,2}
fmt.Println("Ordre strict :", orderedAlts)
lambda:=TieBreakFactory(orderedAlts)
bestAlts := []Alternative{3,6}
fmt.Println("Premières alternatives à départager :", bestAlts)
bestAlt,_ := lambda(bestAlts)
fmt.Println("Première alternative :", bestAlt)
}
// func SWFFactory(func swf(p Profile) (Count, error), func ([]Alternative) (Alternative, error)) (func(Profile) ([]Alternative, error)){
// return func ([]Alternative) (Alternative, error) {
// return orderedAlts[0],nil
// }
// }
//func SCFFactory(func scf(p Profile) ([]Alternative, error), func ([]Alternative) (Alternative, error)) (func(Profile) (Alternative, error))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment