1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
//!
//! The logical functions are: TRUE() and FALSE(); the functions that compute
//! Logical values NOT(), AND(), and OR(); and the conditional function IF().
//! The OpenDocument specification mentions "logical operators"; these are
//! another name for the logical functions.
//!
//! Note that because of Error values, any logical function that accepts
//! parameters can actually produce TRUE, FALSE, or an Error value instead of
//! TRUE or FALSE.
//!
//! These are not bitwise operations, e.g., AND(12;10) produces TRUE, not 8.
//! See the bit operation functions for bitwise operations.
use crate::*;
use crate*;
/// Compute logical AND of all parameters.
///
/// [documentfoundation->AND](https://wiki.documentfoundation.org/Documentation/Calc_Functions/AND)
///
/// __Syntax__:
/// ```ods
/// AND({ L: Logical|NumberSequenceList}+ )
/// ```
///
/// __Constraints__:
/// Shall have 1 or more parameters
///
/// __Semantics__:
/// Computes the logical AND of the parameters. If all parameters are TRUE,
/// returns TRUE; if any are FALSE, returns FALSE. When given one parameter,
/// this has the effect of converting that one parameter into a Logical value.
/// When given zero parameters, evaluators may return a Logical value or an
/// Error.
///
/// Also in array context a logical AND of all arguments is computed, range or
/// array parameters are not evaluated as a matrix and no array is returned.
/// This behavior is consistent with functions like SUM. To compute a logical
/// AND of arrays per element use the * operator in array context.
///
/// __See also__: [crate::of::or()], [crate::of::if_()],
/// Returns constant FALSE.
///
/// [documentfoundation->FALSE](https://wiki.documentfoundation.org/Documentation/Calc_Functions/FALSE)
///
/// __Syntax__:
/// ```ods
/// FALSE( )
/// ```
///
/// __Constraints__:
/// Shall have 0 parameters
///
/// __Semantics__:
/// Returns logical constant FALSE. This may be a Number or a distinct type.
///
/// __See also__: [crate::of::true_()], [crate::of::if_()],
/// Return one of two values, depending on a condition.
///
/// [documentfoundation->IF](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IF)
///
/// __Syntax__:
/// ```ods
/// IF( Condition: Logical )
/// ```
///
/// __Constraints__:
/// None.
///
/// __Semantics__:
/// Computes Condition. If it is TRUE, it returns IfTrue, else it returns
/// IfFalse. This function only evaluates IfTrue, or IfFalse, and never both;
/// that is to say, it short-circuits.
///
/// Seven versions are possible:
///
/// One parameter:
///
/// a)IF(Condition)
///
/// Two parameters:
///
/// b)IF(Condition;)
///
/// c)IF(Condition;IfTrue)
///
/// Three parameters:
///
/// d)IF(Condition;;)
///
/// e)IF(Condition;;IfFalse)
///
/// f)IF(Condition;IfTrue;)
///
/// g)IF(Condition;IfTrue;IfFalse)
///
/// If there is only 1 parameter (case a), IfTrue is considered to be TRUE and
/// IfFalse is considered to be FALSE. Thus the 1 parameter version converts
/// Condition into a Logical value.
///
/// If there are 2 parameters (cases b and c), IfFalse is considered to be
/// FALSE. If there are 2 parameters and the second parameter is null
/// (semicolon but no IfTrue, case b), IfTrue is considered to be 0.
///
/// If there are 3 parameters but the second parameter is null (two consecutive
/// ;; semicolons, cases d and e), IfTrue is considered to be 0.
///
/// If there are 3 parameters but the third parameter is null (semicolon but no
/// IfFalse, cases d and f), IfFalse is considered to be 0.
///
/// __See also__: [crate::of::and()], [crate::of::or()], [crate::of::if__()], [crate::of::if___()],
/// Return one of two values, depending on a condition.
///
/// [documentfoundation->IF](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IF)
///
/// __Syntax__:
/// ```ods
/// IF( Condition: Logical; IfTrue: Any )
/// ```
///
/// __Constraints__:
/// None.
///
/// __Semantics__:
/// Computes Condition. If it is TRUE, it returns IfTrue, else it returns
/// IfFalse. This function only evaluates IfTrue, or IfFalse, and never both;
/// that is to say, it short-circuits.
///
/// Seven versions are possible:
///
/// One parameter:
///
/// a)IF(Condition)
///
/// Two parameters:
///
/// b)IF(Condition;)
///
/// c)IF(Condition;IfTrue)
///
/// Three parameters:
///
/// d)IF(Condition;;)
///
/// e)IF(Condition;;IfFalse)
///
/// f)IF(Condition;IfTrue;)
///
/// g)IF(Condition;IfTrue;IfFalse)
///
/// If there is only 1 parameter (case a), IfTrue is considered to be TRUE and
/// IfFalse is considered to be FALSE. Thus the 1 parameter version converts
/// Condition into a Logical value.
///
/// If there are 2 parameters (cases b and c), IfFalse is considered to be
/// FALSE. If there are 2 parameters and the second parameter is null
/// (semicolon but no IfTrue, case b), IfTrue is considered to be 0.
///
/// If there are 3 parameters but the second parameter is null (two consecutive
/// ;; semicolons, cases d and e), IfTrue is considered to be 0.
///
/// If there are 3 parameters but the third parameter is null (semicolon but no
/// IfFalse, cases d and f), IfFalse is considered to be 0.
///
/// __See also__: [crate::of::and()], [crate::of::or()], [crate::of::if_()], [crate::of::if___()],
/// Return one of two values, depending on a condition.
///
/// [documentfoundation->IF](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IF)
///
/// __Syntax__:
/// ```ods
/// IF( Condition: Logical; IfTrue: Any; IfFalse: Any )
/// ```
///
/// __Constraints__:
/// None.
///
/// __Semantics__:
/// Computes Condition. If it is TRUE, it returns IfTrue, else it returns
/// IfFalse. This function only evaluates IfTrue, or IfFalse, and never both;
/// that is to say, it short-circuits.
///
/// Seven versions are possible:
///
/// One parameter:
///
/// a)IF(Condition)
///
/// Two parameters:
///
/// b)IF(Condition;)
///
/// c)IF(Condition;IfTrue)
///
/// Three parameters:
///
/// d)IF(Condition;;)
///
/// e)IF(Condition;;IfFalse)
///
/// f)IF(Condition;IfTrue;)
///
/// g)IF(Condition;IfTrue;IfFalse)
///
/// If there is only 1 parameter (case a), IfTrue is considered to be TRUE and
/// IfFalse is considered to be FALSE. Thus the 1 parameter version converts
/// Condition into a Logical value.
///
/// If there are 2 parameters (cases b and c), IfFalse is considered to be
/// FALSE. If there are 2 parameters and the second parameter is null
/// (semicolon but no IfTrue, case b), IfTrue is considered to be 0.
///
/// If there are 3 parameters but the second parameter is null (two consecutive
/// ;; semicolons, cases d and e), IfTrue is considered to be 0.
///
/// If there are 3 parameters but the third parameter is null (semicolon but no
/// IfFalse, cases d and f), IfFalse is considered to be 0.
///
/// __See also__: [crate::of::and()], [crate::of::or()], [crate::of::if_()], [crate::of::if__()],
/// Return X unless it is an Error, in which case return an alternative value.
///
/// [documentfoundation->IFERROR](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IFERROR)
///
/// __Syntax__:
/// ```ods
/// IFERROR( X: Any; Alternative: Any )
/// ```
///
/// __Constraints__:
/// None.
///
/// __Semantics__:
/// Computes X. If ISERROR(X) is TRUE, return Alternative, else return X.
///
/// __Note__:
/// This is semantically equivalent to IF(ISERROR(X); Alternative; X), except
/// that X is only computed once.
///
/// __See also__: [crate::of::if_()], [crate::of::iserror()],
/// Return X unless it is #N/A, in which case return an alternative value.
///
/// [documentfoundation->IFNA](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IFNA)
///
/// __Syntax__:
/// ```ods
/// IFNA( X: Any; Alternative: Any )
/// ```
///
/// __Constraints__:
/// None.
///
/// __Semantics__:
/// Computes X. If ISNA(X) is TRUE, return Alternative, else return X.
///
/// __Note__:
/// This is semantically equivalent to IF(ISNA(X); Alternative; X), except that
/// X is only computed once.
///
/// __See also__: [crate::of::if_()], [crate::of::isna()],
/// Compute logical NOT.
///
/// [documentfoundation->NOT](https://wiki.documentfoundation.org/Documentation/Calc_Functions/NOT)
///
/// __Syntax__:
/// ```ods
/// NOT( L: Logical )
/// ```
///
/// __Constraints__:
/// Shall have 1 parameter.
///
/// __Semantics__:
/// Computes the logical NOT. If given TRUE, returns FALSE; if given FALSE,
/// returns TRUE.
///
/// __See also__: [crate::of::and()], [crate::of::if_()],
/// Compute logical OR of all parameters.
///
/// [documentfoundation->OR](https://wiki.documentfoundation.org/Documentation/Calc_Functions/OR)
///
/// __Syntax__:
/// ```ods
/// OR({ L: Logical|NumberSequenceList}+ )
/// ```
///
/// __Constraints__:
/// Shall have 1 or more parameters
///
/// __Semantics__:
/// Computes the logical OR of the parameters. If all parameters are FALSE, it
/// shall return FALSE; if any are TRUE, it shall returns TRUE. When given one
/// parameter, this has the effect of converting that one parameter into a
/// Logical value. When given zero parameters, evaluators may return a Logical
/// value or an Error.
///
/// Also in array context a logical OR of all arguments is computed, range or
/// array parameters are not evaluated as a matrix and no array is returned.
/// This behavior is consistent with functions like SUM. To compute a logical
/// OR of arrays per element use the + operator in array context.
///
/// __See also__: [crate::of::and()], [crate::of::if_()],
/// Returns constant TRUE
///
/// [documentfoundation->TRUE](https://wiki.documentfoundation.org/Documentation/Calc_Functions/TRUE)
///
/// __Syntax__:
/// ```ods
/// TRUE( )
/// ```
///
/// __Constraints__:
/// Shall have 0 parameters
///
/// __Semantics__:
/// Returns logical constant TRUE. The result of this function may but need not
/// be equal to 1 when compared using “=”. It always has the value of 1 if
/// used in a context requiring Number (because of the automatic conversions),
/// so if ISNUMBER(TRUE()) is TRUE, then it shall have the value 1.
///
/// __See also__: [crate::of::false_()], [crate::of::if_()], [crate::of::isnumber()],
/// Compute a logical XOR of all parameters.
///
/// [documentfoundation->XOR](https://wiki.documentfoundation.org/Documentation/Calc_Functions/XOR)
///
/// __Syntax__:
/// ```ods
/// XOR({ L: Logical}+ )
/// ```
///
/// __Constraints__:
/// Shall have 1 or more parameters.
///
/// __Semantics__:
/// Computes the logical XOR of the parameters such that the result is an
/// addition modulo 2. If an even number of parameters is TRUE it returns
/// FALSE, if an odd number of parameters is TRUE it returns TRUE. When given
/// one parameter, this has the effect of converting that one parameter into a
/// Logical value.
///
/// __See also__: [crate::of::and()], [crate::of::or()],