Decision tables: Difference between revisions

Content deleted Content added
Sonia (talk | contribs)
→‎{{header|Go}}: language change. built in error type.
Line 275:
 
import (
"errors"
"fmt"
"os"
Line 297 ⟶ 298:
type dtMap map[string][]string
 
func compileDT(t []dtText) (dtMap, os.Errorerror) {
if len(t) == 0 {
return nil, oserrors.NewErrorNew("Empty decision table")
}
var conditions, actions []dtText
Line 305 ⟶ 306:
for i, row := range t {
if len(row.rules) != ruleColumns {
return nil, oserrors.NewErrorNew("Inconsistent number of rule columns")
}
if len(row.text) == 0 {
if conditions != nil {
return nil, oserrors.NewErrorNew("Multple separator lines")
}
if i == 0 {
return nil, oserrors.NewErrorNew("No conditions specified")
}
if i == len(t)-1 {
return nil, oserrors.NewErrorNew("No actions specified")
}
conditions = t[:i]
Line 322 ⟶ 323:
}
if conditions == nil {
return nil, oserrors.NewErrorNew("Missing separator line")
}
m := make(map[string][]string, ruleColumns)
Line 341 ⟶ 342:
 
func init() {
var err os.Errorerror
if ptMap, err = compileDT(ptText); err != nil {
fmt.Println(err)