site/contents/reference-logic.md
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 |
----- content-type: "page" title: "logic Module" ----- {@ _defs_.md || 0 @} {#op||>||{{a1}} {{a2}}||{{b}}|| > Returns {{t}} if {{a1}} is greater than {{a2}}, {{f}} otherwise. > > %note% > > Note > > > > Only comparisons among two numbers or two strings are supported.#} {#op||>=||{{a1}} {{a2}}||{{b}}|| > Returns {{t}} if {{a1}} is greater than or equal to {{a2}}, {{f}} otherwise. > > %note% > > Note > > > > Only comparisons among two numbers or two strings are supported.#} {#op||<||{{a1}} {{a2}}||{{b}}|| > Returns {{t}} if {{a1}} is smaller than {{a2}}, {{f}} otherwise. > > %note% > > Note > > > > Only comparisons among two numbers or two strings are supported.#} {#op||<=||{{a1}} {{a2}}||{{b}}|| > Returns {{t}} if {{a1}} is smaller than or equal to {{a2}}, {{f}} otherwise. > > %note% > > Note > > > > Only comparisons among two numbers or two strings are supported.#} {#op||==||{{a1}} {{a2}}||{{b}}|| Returns {{t}} if {{a1}} is equal to {{a2}}, {{f}} otherwise. #} {#op||!=||{{a1}} {{a2}}||{{b}}|| Returns {{t}} if {{a1}} is not equal to {{a2}}, {{f}} otherwise. #} {#op||and||{{b1}} {{b2}}||{{b3}}|| Returns {{t}} if {{b1}} is equal to {{b2}}, {{f}} otherwise.#} {#op||boolean?||{{any}}||{{b}}|| Returns {{t}} if {{any}} is a boolean, {{f}} otherwise. #} {#op||dequote-and||{{a1}} {{a2}}||{{b}}|| > Short-circuited logical and. It performs the following operations: > > 1. Pops {{a1}} and {{a2}} off the stack. > 2. Dequotes {{a1}}, if {{f}} is on the stack, it pushes {{f}} on the stack and stops, otherwise it carries on. > 3. Dequotes {{a2}}. > 4. If {{a2}} is {{t}}, it pushes {{t}} on the stack. > > > %note% > > Note > > > > {{a1}} (and {{a2}}, if dequoted) must evaluate to a boolean value, otherwise an exception is raised. > > > %sidebar% > > Example > > > > The following program returns {{f}} and never executes the second quotation. > > > > "test" :x (x number?) (x 5 <) dequote-and #} {#op||dequote-or||{{a1}} {{a2}}||{{b}}|| > Short-circuited logical or. It performs the following operations: > > 1. Pops {{a1}} and {{a2}} off the stack. > 2. Dequotes {{a1}}, if {{t}} is on the stack, it pushes {{t}} on the stack and stops, otherwise it carries on. > 3. Dequotes {{a2}}. > 4. If {{a2}} is {{f}}, it pushes {{f}} on the stack. > > > %note% > > Note > > > > {{a1}} (and {{a2}}, if dequoted) must evaluate to a boolean value, otherwise an exception is raised. > > > %sidebar% > > Example > > > > The following program returns {{t}} and never executes the second quotation. > > > > "test" :x (x string?) (x quotation?) dequote-or #} {#op||dictionary?||{{any}}||{{b}}|| Returns {{t}} if {{any}} is a dictionary, {{f}} otherwise. #} {#op||float?||{{any}}||{{b}}|| Returns {{t}} if {{any}} is a float, {{f}} otherwise. #} {#op||or||{{b1}} {{b2}}||{{b3}}|| Returns {{t}} if {{b1}} or {{b2}} is {{t}}, {{f}} otherwise.#} {#op||integer?||{{any}}||{{b}}|| Returns {{t}} if {{any}} is an integer, {{f}} otherwise. #} {#op||not||{{b1}}||{{b2}}|| Negates {{b1}}.#} {#op||null?||{{any}}||{{b}}|| Returns {{t}} if {{any}} is {{null}}, {{f}} otherwise. #} {#op||number?||{{any}}||{{b}}|| Returns {{t}} if {{any}} is a number, {{f}} otherwise. #} {#op||quotation?||{{any}}||{{b}}|| Returns {{t}} if {{any}} is a quotation, {{f}} otherwise. #} {#op||type?||{{any}} {{sl}}||{{b}}|| Returns {{t}} if the data type of {{any}} is the specified type {{sl}}, {{f}} otherwise. #} {#op||xor||{{b1}} {{b2}}||{{b3}}|| Returns {{t}} if {{b1}} and {{b2}} are different, {{f}} otherwise.#} |