| 1092 | complexity: 11200, |
| 1093 | signature: '(any, any) -> boolean', |
| 1094 | description: 'Test whether a value is not an element of a collection.', |
| 1095 | canonical: (args, { engine: ce }) => { |
| 1096 | // Same collection leniency as `Element` (which accepts `K_a \in BC`): |
| 1097 | // without this handler, generic signature validation rejects a label |
| 1098 | // collection (`K_a \notin BC`, where `BC` is a geometry line label). |
| 1099 | if (args.length < 2) |
| 1100 | return ce._fn('NotElement', [ |
| 1101 | args[0]?.canonical ?? ce.error('missing'), |
| 1102 | ce.error('missing'), |
| 1103 | ]); |
| 1104 | const [value, collection] = args; |
| 1105 | return ce._fn('NotElement', [value.canonical, collection.canonical]); |
| 1106 | }, |
| 1107 | evaluate: ([value, collection], { engine: ce }) => { |
| 1108 | if (!collection) return undefined; |
| 1109 | // As for `Element`: a `Sort` that could not order its elements is read |
| 1110 | // as its source. |
| 1111 | collection = orderIndependentSource(collection, peekMembershipPreserving); |
| 1112 | // An absent value is an ordinary element to search for (see `Element`). |
| 1113 | const result = membershipKleene(ce, value, collection); |
| 1114 | if (result === true) return ce.False; |
| 1115 | if (result === undefined && collection.isValid) return undefined; |
| 1116 | // As for `Element`: a failed cell could be the value. |
| 1117 | const failed = firstFailedElementError(collection); |
| 1118 | if (failed === 'incomplete') return undefined; |
| 1119 | if (failed !== undefined) return failed; |
| 1120 | return result === undefined ? undefined : ce.True; |
| 1121 | }, |
| 1122 | }, |
| 1123 | |
| 1124 | // `Subset`, `SubsetEqual`, `Superset` and `SupersetEqual` declare |