Skip to content
Snippets Groups Projects
Commit 14d9ab39 authored by Mohamed Fall's avatar Mohamed Fall
Browse files

Merge branch 'main' of gitlab.utc.fr:fallmoha/IA04_TP3

parents e477f74e 01082afe
No related branches found
No related tags found
No related merge requests found
package comsoc
func TieBreakFactory([]Alternative) func([]Alternative) (Alternative, err error) {
}
File moved
File moved
File moved
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
// }
File moved
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