Given a predicate for comparing individual elements, produce a new predicate that implements the "in" comparison.
(compare Boolean)
| 266 | // Given a predicate for comparing individual elements, produce a new |
| 267 | // predicate that implements the "in" comparison. |
| 268 | func Contains(compare Boolean) Boolean { |
| 269 | return func(val super.Value) super.Value { |
| 270 | err := val.Walk(func(typ super.Type, body scode.Bytes) error { |
| 271 | if compare(super.NewValue(typ, body)) == super.True { |
| 272 | return errMatch |
| 273 | } |
| 274 | return nil |
| 275 | }) |
| 276 | return super.NewBool(err == errMatch) |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | // Comparison returns a Predicate for comparing this value to other values. |
| 281 | // The op argument is one of "==", "!=", "<", "<=", ">", ">=". |
no test coverage detected