From 6a7d973172a4985cadda8346faaf01949448d413 Mon Sep 17 00:00:00 2001 From: 10756864 <antoine.kryus@etu.utc.fr> Date: Thu, 13 Oct 2022 16:43:45 +0200 Subject: [PATCH] mov files --- comsoc/tieBreak.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/comsoc/tieBreak.go b/comsoc/tieBreak.go index 24f91cd..5fbe9ea 100644 --- a/comsoc/tieBreak.go +++ b/comsoc/tieBreak.go @@ -1 +1,51 @@ package comsoc + +import("errors") + +func TieBreakFactory(tieBreakAlts []Alternative) (func ([]Alternative) (Alternative, err error)) { + return func(alts []Alternative) (Alternative, err error) { + if len(alts) == 0 || alts == nil { + return -1, errors.New("002: NullAlternatives") + } + + for _,alt := range(alts) { + for _,tieBreakAlt := range(tieBreakAlts) { + if alt == tieBreakAlt { + return alt, nil + } + } + } + return -1, errors.New("002: NoTieBreakAlternativeFound") + } +} + +func SWFFactory(swf1 func (Profile) (Count, error), tieBreak func ([]Alternative) (Alternative, error)) (swf2 func(Profile) (alts []Alternative, err error)) { + return func(p Profile) (alts Alternative, err error) { + // alts, _ := maxCount(swf1(p)) + // alt, _ := tieBreak(alts) + // return alt, nil + // il faut trifouiller le count + } +} + + +func SCFFactory(scf1 func (Profile) ([]Alternative, error), tieBreak func ([]Alternative) (Alternative, error)) (scf2 func(Profile) (alt Alternative, err error)) { + return func(p Profile) (alt Alternative, err error) { + alts, _ := scf1(p) + alt, _ := tieBreak(alts) + return alt, nil + } +} + + + + +// func TieBreak(a []Alternative) (Alternative, err error) { +// // if len(a) == 0 || a == nil { +// // return _, errors.New("002: NullAlternatives") +// // } +// // for _,alt := range a { +// // +// // } // 0-votes alternatives are not included +// // return nil, nil +// } -- GitLab