mirror of
https://github.com/gorules/zen.git
synced 2026-10-04 08:02:28 +00:00
18 KiB
18 KiB
| 1 | expression (string);input (json 5);output (json 5) | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2 | # Boolean | |||||||||||
| 3 | true and true;;true | |||||||||||
| 4 | true and false;;false | |||||||||||
| 5 | false and true;;false | |||||||||||
| 6 | false and false;;false | |||||||||||
| 7 | true or true;;true | |||||||||||
| 8 | true or false;;true | |||||||||||
| 9 | false or true;;true | |||||||||||
| 10 | false or false;;false | |||||||||||
| 11 | not true;;false | |||||||||||
| 12 | not false;;true | |||||||||||
| 13 | # Numbers | |||||||||||
| 14 | 1 == 1;;true | |||||||||||
| 15 | 1 == 2;;false | |||||||||||
| 16 | 1 != 2;;true | |||||||||||
| 17 | 1 != 1;;false | |||||||||||
| 18 | 1 < 2;;true | |||||||||||
| 19 | 1 < 1;;false | |||||||||||
| 20 | 1 <= 1;;true | |||||||||||
| 21 | 2 <= 1;;false | |||||||||||
| 22 | 2 > 1;;true | |||||||||||
| 23 | 1 > 1;;false | |||||||||||
| 24 | 1 >= 1;;true | |||||||||||
| 25 | 1 >= 2;;false | |||||||||||
| 26 | -1 == -1;;true | |||||||||||
| 27 | -1 == 1;;false | |||||||||||
| 28 | -1 != 1;;true | |||||||||||
| 29 | -1 != -1;;false | |||||||||||
| 30 | -1 < 1;;true | |||||||||||
| 31 | -1 < -1;;false | |||||||||||
| 32 | -1 <= -1;;true | |||||||||||
| 33 | 1 <= -1;;false | |||||||||||
| 34 | 1 > -1;;true | |||||||||||
| 35 | -1 > -1;;false | |||||||||||
| 36 | -1 >= -1;;true | |||||||||||
| 37 | -1 >= 1;;false | |||||||||||
| 38 | 1 + 2 == 3;;true | |||||||||||
| 39 | 1 + 2 == 4;;false | |||||||||||
| 40 | 1 - 2 == -1;;true | |||||||||||
| 41 | 1 - 2 == 0;;false | |||||||||||
| 42 | 2 * 3 == 6;;true | |||||||||||
| 43 | 2 * 3 == 7;;false | |||||||||||
| 44 | 6 / 3 == 2;;true | |||||||||||
| 45 | 6 / 3 == 2.5;;false | |||||||||||
| 46 | 5 % 2 == 1;;true | |||||||||||
| 47 | 6 % 2 == 0;;true | |||||||||||
| 48 | -5 + 5 == 0;;true | |||||||||||
| 49 | -5 * 5 == -25;;true | |||||||||||
| 50 | -5 * -5 == 25;;true | |||||||||||
| 51 | 10 / 0;;null | |||||||||||
| 52 | abs(-5) == 5;;true | |||||||||||
| 53 | abs(5) == 5;;true | |||||||||||
| 54 | 2 ^ 3 == 8;;true | |||||||||||
| 55 | 2 ^ -1 == 0.5;;true | |||||||||||
| 56 | max([3 | 5]) == 5;;true | ||||||||||
| 57 | max([-3 | -5]) == -3;;true | ||||||||||
| 58 | min([3 | 5]) == 3;;true | ||||||||||
| 59 | min([-3 | -5]) == -5;;true | ||||||||||
| 60 | 3 + 4 * 2;;11 | |||||||||||
| 61 | (3 + 4) * 2;;14 | |||||||||||
| 62 | (10 - 4) / 2;;3 | |||||||||||
| 63 | abs(-5);;5 | |||||||||||
| 64 | sum([1 | 2 | 3 | 4 | 5]);;15 | |||||||
| 65 | avg([10 | 20 | 30]);;20 | |||||||||
| 66 | min([5 | 8 | 2 | 11 | 7]);;2 | |||||||
| 67 | max([5 | 8 | 2 | 11 | 7]);;11 | |||||||
| 68 | floor(4.8);;4 | |||||||||||
| 69 | ceil(4.1);;5 | |||||||||||
| 70 | round(3.5);;4 | |||||||||||
| 71 | rand(100) >= 0 and rand(100) <= 100;;true | |||||||||||
| 72 | median([4 | 2 | 7 | 5 | 3]);;4 | |||||||
| 73 | mode([1 | 2 | 2 | 3 | 3 | 3 | 4 | 4 | 4 | 4]);;4 | ||
| 74 | 5 % 2 == 1;;true | |||||||||||
| 75 | 10 % 4 == 2;;true | |||||||||||
| 76 | true ? 10 == 10 : 20 == 30;;true | |||||||||||
| 77 | false ? 10 == 10 : 20 == 30;;false | |||||||||||
| 78 | true ? 10 == 20 : false ? 30 == 40 : true ? 50 == 60 : 70 == 80;;false | |||||||||||
| 79 | # String | |||||||||||
| 80 | # Template string | |||||||||||
| 81 | `simple template`;;'simple template' | |||||||||||
| 82 | `sum of numbers ${sum([1 | 2 | 3])}`;;'sum of numbers 6' | |||||||||
| 83 | `reference env: ${a}`;{a:'example'};'reference env: example' | |||||||||||
| 84 | `uppercase inner ${upper('string')}`;;'uppercase inner STRING' | |||||||||||
| 85 | # String Slice | |||||||||||
| 86 | string[0:5];{string: 'sample_string'};'sample' | |||||||||||
| 87 | string[7:12];{string: 'sample_string'};'string' | |||||||||||
| 88 | string[7:];{string: 'sample_string'};'string' | |||||||||||
| 89 | string[:5];{string: 'sample_string'};'sample' | |||||||||||
| 90 | # Array | |||||||||||
| 91 | len([1 | 2 | 3 | 4 | 5]);; 5 | |||||||
| 92 | sum([1 | 2 | 3 | 4 | 5]);; 15 | |||||||
| 93 | avg([10 | 20 | 30]);; 20 | |||||||||
| 94 | min([5 | 8 | 2 | 11 | 7]);; 2 | |||||||
| 95 | max([5 | 8 | 2 | 11 | 7]);; 11 | |||||||
| 96 | contains([1 | 2 | 3 | 4 | 5] | 3);; true | ||||||
| 97 | contains([1 | 2 | 3 | 4 | 5] | 6);; false | ||||||
| 98 | count([1 | 2 | 3 | 4 | 5 | 2] | # == 2);; 2 | |||||
| 99 | filter([1 | 2 | 3 | 4 | 5] | # > 3);; [4 | 5] | |||||
| 100 | map([1 | 2 | 3 | 4 | 5] | # * 2);; [2 | 4 | 6 | 8 | 10] | ||
| 101 | one([1 | 2 | 3 | 4 | 5] | # == 3);; true | ||||||
| 102 | one([1 | 2 | 3 | 4 | 5] | # == 6);; false | ||||||
| 103 | none([1 | 2 | 3 | 4 | 5] | # > 5);; true | ||||||
| 104 | some([1 | 2 | 3 | 4 | 5] | # > 3);; true | ||||||
| 105 | flatMap([[1 | 2] | [3 | 4] | [5 | 6]] | #);; [1 | 2 | 3 | 4 | 5 | 6] |
| 106 | keys([10 | 11 | 12]);;[0 | 1 | 2] | |||||||
| 107 | # Dates | |||||||||||
| 108 | # Decimal precision | |||||||||||
| 109 | 0.1 + 0.2 == 0.3;; true | |||||||||||
| 110 | 0.1 + 0.2;; 0.3 | |||||||||||
| 111 | 0.1 * 0.2 == 0.02;; true | |||||||||||
| 112 | 0.1 * 0.2;; 0.02 | |||||||||||
| 113 | 0.3 - 0.1 == 0.2;; true | |||||||||||
| 114 | 0.3 - 0.1;; 0.2 | |||||||||||
| 115 | 0.3 / 0.1 == 3.0;; true | |||||||||||
| 116 | 0.3 / 0.1;; 3 | |||||||||||
| 117 | # More complex formulas | |||||||||||
| 118 | (10 + 5) * 3 / 2 > 15;; true | |||||||||||
| 119 | (100 - 25) / (5 * 2) < 10;; true | |||||||||||
| 120 | 1000 / (10 - 2) + 50 == 175;; true | |||||||||||
| 121 | (3 + 4) * (8 - 6) == 14;; true | |||||||||||
| 122 | 10^3 != 999;; true | |||||||||||
| 123 | 1000 / 10^3 <= 1.1;; true | |||||||||||
| 124 | abs(-20) > 10;; true | |||||||||||
| 125 | floor(8.9) == 8;; true | |||||||||||
| 126 | ceil(8.1) == 9;; true | |||||||||||
| 127 | round(7.6) == 8;; true | |||||||||||
| 128 | 10 % 3 != 0;; true | |||||||||||
| 129 | -8 + 2^3 == 0;; true | |||||||||||
| 130 | 2 * -(-5) == 10;; true | |||||||||||
| 131 | 20 / (5 / 2) == 8.0;; true | |||||||||||
| 132 | (4 + 2) * 3 - (5 / 2) + 1 < 18;; true | |||||||||||
| 133 | 5^2 + 3 * 4 - 6 / 2 > 20;; true | |||||||||||
| 134 | 4^3 - 2 * 5 + 7 / 2 == 57.5;; true | |||||||||||
| 135 | abs(-7 + 4) * (8 - 6^2) < 34;; true | |||||||||||
| 136 | 5 in [1..10];; true | |||||||||||
| 137 | 5 in (1..10);; true | |||||||||||
| 138 | 5 not in [1..10);; false | |||||||||||
| 139 | 5 not in (1..10);; false | |||||||||||
| 140 | -5 in [-10..-1];; true | |||||||||||
| 141 | -5 in [-10..-1);; true | |||||||||||
| 142 | -5 not in [-10..-1];; false | |||||||||||
| 143 | -5 not in [-10..-1);; false | |||||||||||
| 144 | -5 in [-5..5];; true | |||||||||||
| 145 | -5 in (-5..5);; false | |||||||||||
| 146 | -5 not in [-5..5);; false | |||||||||||
| 147 | -5 not in (-5..5);; true | |||||||||||
| 148 | 10 > 5;; true | |||||||||||
| 149 | 5 < 10;; true | |||||||||||
| 150 | 10 >= 10;; true | |||||||||||
| 151 | 5 <= 5;; true | |||||||||||
| 152 | (1 + 2) == 3;; true | |||||||||||
| 153 | (1 + 2) != 4;; true | |||||||||||
| 154 | (1 + 2) > 2;; true | |||||||||||
| 155 | (1 + 2) < 5;; true | |||||||||||
| 156 | # Date Functions | |||||||||||
| 157 | dateString(startOf('2023-01-01 15:45:01' | 'day'));;'2023-01-01 00:00:00' | ||||||||||
| 158 | dateString(endOf('2023-01-01 15:45:01' | 'd'));;'2023-01-01 23:59:59' | ||||||||||
| 159 | dateString(startOf('2023-01-01 15:45:01' | 'hour'));;'2023-01-01 15:00:00' | ||||||||||
| 160 | dateString(endOf('2023-01-01 15:45:01' | 'h'));;'2023-01-01 15:59:59' | ||||||||||
| 161 | dateString(startOf('2023-01-01 15:45:01' | 'minute'));;'2023-01-01 15:45:00' | ||||||||||
| 162 | dateString(endOf('2023-01-01 15:45:01' | 'm'));;'2023-01-01 15:45:59' | ||||||||||
| 163 | dateString(startOf('2023-01-04 15:45:01' | 'week'));;'2023-01-02 00:00:00' | ||||||||||
| 164 | dateString(endOf('2023-01-04 15:45:01' | 'w'));;'2023-01-08 23:59:59' | ||||||||||
| 165 | dateString(startOf('2023-01-04 15:45:01' | 'month'));;'2023-01-01 00:00:00' | ||||||||||
| 166 | dateString(endOf('2023-01-04 15:45:01' | 'M'));;'2023-01-31 23:59:59' | ||||||||||
| 167 | dateString(startOf('2023-01-04 15:45:01' | 'year'));;'2023-01-01 00:00:00' | ||||||||||
| 168 | dateString(endOf('2023-01-04 15:45:01' | 'y'));;'2023-12-31 23:59:59' | ||||||||||
| 169 | # Type conversions | |||||||||||
| 170 | string(123.123);;'123.123' | |||||||||||
| 171 | string(123);;'123' | |||||||||||
| 172 | string(true);;'true' | |||||||||||
| 173 | string(false);;'false' | |||||||||||
| 174 | string('already string');;'already string' | |||||||||||
| 175 | number('123.123');;123.123 | |||||||||||
| 176 | number('123');;123 | |||||||||||
| 177 | number(123.123);;123.123 | |||||||||||
| 178 | number(123);;123 | |||||||||||
| 179 | number(true);;1 | |||||||||||
| 180 | number(false);;0 | |||||||||||
| 181 | # Type check | |||||||||||
| 182 | isNumeric(123.123);;true | |||||||||||
| 183 | isNumeric(123);;true | |||||||||||
| 184 | isNumeric('123.123');;true | |||||||||||
| 185 | isNumeric('123');;true | |||||||||||
| 186 | isNumeric('string');;false | |||||||||||
| 187 | isNumeric(true);;false | |||||||||||
| 188 | # Types | |||||||||||
| 189 | type('hello');;'string' | |||||||||||
| 190 | type(123);;'number' | |||||||||||
| 191 | type(true);;'bool' | |||||||||||
| 192 | type(null);;'null' | |||||||||||
| 193 | type([1 | 2 | 3]);;'array' | |||||||||
| 194 | # Object | |||||||||||
| 195 | sum(values({a: 1 | b: 2 | c: 3}));;6 | |||||||||
| 196 | keys({[`dynamic-${'key'}`]: 123});;['dynamic-key'] | |||||||||||
| 197 | {};;{} | |||||||||||
| 198 | # Interval iterator | |||||||||||
| 199 | map([0..3] | #);[0 | 1 | 2 | 3] | |||||||
| 200 | map((0..3] | #);[1 | 2 | 3] | ||||||||
| 201 | map([0..3) | #);[0 | 1 | 2] | ||||||||
| 202 | map((0..3) | #);[1 | 2] | |||||||||
| 203 | # Nullish coalescing | |||||||||||
| 204 | null ?? 'hello';;'hello' | |||||||||||
| 205 | null ?? 123 ?? 321;;123 | |||||||||||
| 206 | null ?? null ?? 321;;321 | |||||||||||
| 207 | false or true ? null ?? 'test' : false;;'test' | |||||||||||
| 208 | # Array indexing and dot notation | |||||||||||
| 209 | # Array functions | |||||||||||
| 210 | len(['a' | 'b' | 'c']);;3 | |||||||||
| 211 | contains(['a' | 'b' | 'c'] | 'b');;true | ||||||||
| 212 | contains(['a' | 'b' | 'c'] | 'd');;false | ||||||||
| 213 | some(['a' | 'b' | 'c'] | # == 'b');;true | ||||||||
| 214 | some(['a' | 'b' | 'c'] | # == 'd');;false | ||||||||
| 215 | all(['a' | 'b' | 'c'] | # in ['a' | 'b' | 'c' | 'd']);;true | |||||
| 216 | all(['a' | 'b' | 'c'] | # in ['a' | 'b']);;false | |||||||
| 217 | filter(['a' | 'b' | 'c' | 'd'] | # in ['a' | 'c']);;['a' | 'c'] | |||||
| 218 | map(['a' | 'b' | 'c'] | # + '!');;['a!' | 'b!' | 'c!'] | ||||||
| 219 | # Array combinations | |||||||||||
| 220 | map(filter([1 | 2 | 3 | 4 | 5] | # > 2) | # * 2);;[6 | 8 | 10] | |||
| 221 | len(filter([1 | 2 | 3 | 4 | 5] | # % 2 == 0));;2 | ||||||
| 222 | sum(filter([1 | 2 | 3 | 4 | 5] | # % 2 == 0));;6 | ||||||
| 223 | sum(map(filter([1 | 2 | 3 | 4 | 5] | # > 3) | # ^ 2));;41 | |||||
| 224 | # Complex array operations | |||||||||||
| 225 | some(map([1 | 2 | 3] | # * 2) | # > 5);;true | |||||||
| 226 | all(map([1 | 2 | 3] | # + 2) | # > 2);;true | |||||||
| 227 | contains(map([1 | 2 | 3] | # * 2) | 6);;true | |||||||
| 228 | contains(values({a: 1 | b: 2 | c: 3}) | 2);;true | ||||||||
| 229 | # Array with objects | |||||||||||
| 230 | map([{id: 1 | name: 'John'} | {id: 2 | name: 'Jane'}] | #.id);;[1 | 2] | ||||||
| 231 | filter([{id: 1 | name: 'John'} | {id: 2 | name: 'Jane'}] | #.id > 1);;[{id: 2 | name: 'Jane'}] | ||||||
| 232 | map(filter([{id: 1 | name: 'John'} | {id: 2 | name: 'Jane'}] | #.id > 1) | #.name);;['Jane'] | ||||||
| 233 | # String concatenation | |||||||||||
| 234 | 'Hello' + ' ' + 'World' + '!';;'Hello World!' | |||||||||||
| 235 | # String functions | |||||||||||
| 236 | len('Hello');;5 | |||||||||||
| 237 | upper('Hello');;'HELLO' | |||||||||||
| 238 | lower('HELLO');;'hello' | |||||||||||
| 239 | trim(' hello ');;'hello' | |||||||||||
| 240 | startsWith('Hello World' | 'Hell');;true | ||||||||||
| 241 | endsWith('Hello World' | 'orld');;true | ||||||||||
| 242 | contains('Hello World' | 'lo Wo');;true | ||||||||||
| 243 | matches('123-456-7890' | '[0-9]{3}-[0-9]{3}-[0-9]{4}');;true | ||||||||||
| 244 | # String formatting | |||||||||||
| 245 | `Total: ${sum([1 | 2 | 3])}`;;'Total: 6' | |||||||||
| 246 | # Nested object access | |||||||||||
| 247 | # Dynamic keys | |||||||||||
| 248 | # Date arithmetic | |||||||||||
| 249 | date('2023-10-15') + duration('1d');;1697414400 | |||||||||||
| 250 | date('2023-10-15') - duration('7d');;1696723200 | |||||||||||
| 251 | dateString(date('2023-10-15') + duration('1d'));;'2023-10-16 00:00:00' | |||||||||||
| 252 | dateString(date('2023-10-15') - duration('7d'));;'2023-10-08 00:00:00' | |||||||||||
| 253 | # Date comparisons | |||||||||||
| 254 | date('2023-10-15') > date('2023-10-14');;true | |||||||||||
| 255 | date('2023-10-15') < date('2023-10-16');;true | |||||||||||
| 256 | date('2023-10-15') + duration('1d') == date('2023-10-16');;true | |||||||||||
| 257 | # Date parts | |||||||||||
| 258 | year(date('2023-10-15'));;2023 | |||||||||||
| 259 | monthOfYear(date('2023-10-15'));;10 | |||||||||||
| 260 | dayOfMonth(date('2023-10-15'));;15 | |||||||||||
| 261 | dayOfWeek(date('2023-10-15'));;7 | |||||||||||
| 262 | weekOfYear(date('2023-10-15'));;41 | |||||||||||
| 263 | # Date formatting | |||||||||||
| 264 | dateString(date('2023-10-15'));;'2023-10-15 00:00:00' | |||||||||||
| 265 | dateString(date('2023-10-15') + duration('12h'));;'2023-10-15 12:00:00' | |||||||||||
| 266 | # Ternary operators | |||||||||||
| 267 | # Null handling | |||||||||||
| 268 | # Type conversions | |||||||||||
| 269 | string(123);;'123' | |||||||||||
| 270 | string(true);;'true' | |||||||||||
| 271 | number('123');;123 | |||||||||||
| 272 | number('12.3');;12.3 | |||||||||||
| 273 | number(true);;1 | |||||||||||
| 274 | number(false);;0 | |||||||||||
| 275 | bool(1);;true | |||||||||||
| 276 | bool(0);;false | |||||||||||
| 277 | bool('true');;true | |||||||||||
| 278 | bool('false');;false | |||||||||||
| 279 | # Complex nested expressions | |||||||||||
| 280 | len(filter(map([1 | 2 | 3 | 4 | 5] | # * 2) | # > 5));;3 | |||||
| 281 | sum(map(filter([{id: 1 | val: 10} | {id: 2 | val: 20} | {id: 3 | val: 30}] | #.id > 1) | #.val));;50 | ||||
| 282 | # Data transformation | |||||||||||
| 283 | # Array-based conditions | |||||||||||
| 284 | # Statistical calculations | |||||||||||
| 285 | # Closures and the # symbol | |||||||||||
| 286 | map([1 | 2 | 3] | # * 2);;[2 | 4 | 6] | ||||||
| 287 | filter([1 | 2 | 3 | 4 | 5] | # % 2 == 0);;[2 | 4] | |||||
| 288 | some([1 | 2 | 3] | # > 2);;true | ||||||||
| 289 | all([1 | 2 | 3] | # > 0);;true | ||||||||
| 290 | count([1 | 2 | 2 | 3 | 3 | 3] | # == 3);;3 | |||||
| 291 | one([1 | 2 | 3] | # == 2);;true | ||||||||
| 292 | none([1 | 2 | 3] | # > 3);;true | ||||||||
| 293 | # Nested closures | |||||||||||
| 294 | filter(map([1 | 2 | 3 | 4] | # * 2) | # > 5);;[6 | 8] | |||||
| 295 | map(filter([1 | 2 | 3 | 4] | # % 2 == 0) | # * 3);;[6 | 12] | |||||
| 296 | # Range tests | |||||||||||
| 297 | # Interval iterator | |||||||||||
| 298 | map([0..5] | # * 2);;[0 | 2 | 4 | 6 | 8 | 10] | |||||
| 299 | filter([0..10] | # % 2 == 0);;[0 | 2 | 4 | 6 | 8 | 10] | |||||
| 300 | # Rounding | |||||||||||
| 301 | round(7.4);; 7 | |||||||||||
| 302 | round(7.5);; 8 | |||||||||||
| 303 | round(7.6);; 8 | |||||||||||
| 304 | round(-7.4);; -7 | |||||||||||
| 305 | round(-7.5);; -8 | |||||||||||
| 306 | round(-7.6);; -8 | |||||||||||
| 307 | round(0.5);;1 | |||||||||||
| 308 | round(-0.5);;-1 | |||||||||||
| 309 | round(1.5);;2 | |||||||||||
| 310 | round(-1.5);;-2 | |||||||||||
| 311 | round(0.4);;0 | |||||||||||
| 312 | round(-0.4);;0 | |||||||||||
| 313 | round(7.444 | 0);; 7 | ||||||||||
| 314 | round(7.444 | 1);; 7.4 | ||||||||||
| 315 | round(7.444 | 2);; 7.44 | ||||||||||
| 316 | round(7.555 | 0);; 8 | ||||||||||
| 317 | round(7.555 | 1);; 7.6 | ||||||||||
| 318 | round(7.555 | 2);; 7.56 | ||||||||||
| 319 | round(-7.444 | 2);; -7.44 | ||||||||||
| 320 | round(-7.555 | 2);; -7.56 | ||||||||||
| 321 | trunc(7.4);; 7 | |||||||||||
| 322 | trunc(7.5);; 7 | |||||||||||
| 323 | trunc(7.6);; 7 | |||||||||||
| 324 | trunc(-7.4);; -7 | |||||||||||
| 325 | trunc(-7.5);; -7 | |||||||||||
| 326 | trunc(-7.6);; -7 | |||||||||||
| 327 | trunc(7.444 | 0);; 7 | ||||||||||
| 328 | trunc(7.444 | 1);; 7.4 | ||||||||||
| 329 | trunc(7.444 | 2);; 7.44 | ||||||||||
| 330 | trunc(7.999 | 0);; 7 | ||||||||||
| 331 | trunc(7.999 | 1);; 7.9 | ||||||||||
| 332 | trunc(7.999 | 2);; 7.99 | ||||||||||
| 333 | trunc(-7.444 | 2);; -7.44 | ||||||||||
| 334 | trunc(-7.999 | 2);; -7.99 | ||||||||||
| 335 | # Scientific notation - basic parsing | |||||||||||
| 336 | 1e5;;100000 | |||||||||||
| 337 | 2e3;;2000 | |||||||||||
| 338 | 5e0;;5 | |||||||||||
| 339 | 1e-2;;0.01 | |||||||||||
| 340 | 2.5e2;;250 | |||||||||||
| 341 | 3.14e1;;31.4 | |||||||||||
| 342 | 1.23e-3;;0.00123 | |||||||||||
| 343 | -1e3;;-1000 | |||||||||||
| 344 | -2.5e-2;;-0.025 | |||||||||||
| 345 | # Scientific notation - arithmetic operations | |||||||||||
| 346 | 1e2 + 1e1;;110 | |||||||||||
| 347 | 2e3 - 5e2;;1500 | |||||||||||
| 348 | 3e2 * 2e1;;6000 | |||||||||||
| 349 | 1e4 / 2e2;;50 | |||||||||||
| 350 | 1e2 + 50;;150 | |||||||||||
| 351 | 1e3 - 100;;900 | |||||||||||
| 352 | 2e2 * 3;;600 | |||||||||||
| 353 | 1e3 / 10;;100 | |||||||||||
| 354 | # Scientific notation - comparisons | |||||||||||
| 355 | 1e3 == 1000;;true | |||||||||||
| 356 | 1e3 != 999;;true | |||||||||||
| 357 | 1e2 > 50;;true | |||||||||||
| 358 | 1e2 < 200;;true | |||||||||||
| 359 | 1e2 >= 100;;true | |||||||||||
| 360 | 1e2 <= 100;;true | |||||||||||
| 361 | 2.5e2 == 250;;true | |||||||||||
| 362 | 1.5e-2 == 0.015;;true | |||||||||||
| 363 | # Scientific notation - type conversions | |||||||||||
| 364 | string(1e3);;'1000' | |||||||||||
| 365 | string(2.5e2);;'250' | |||||||||||
| 366 | string(1.23e-3);;'0.00123' | |||||||||||
| 367 | number('1e3');;1000 | |||||||||||
| 368 | number('2.5e2');;250 | |||||||||||
| 369 | number('1.23e-3');;0.00123 | |||||||||||
| 370 | isNumeric('1e3');;true | |||||||||||
| 371 | isNumeric('2.5e-2');;true | |||||||||||
| 372 | isNumeric('1.23e-3');;true | |||||||||||
| 373 | # Scientific notation - array operations | |||||||||||
| 374 | sum([1e2 | 2e2 | 3e2]);;600 | |||||||||
| 375 | max([1e1 | 2e1 | 3e1]);;30 | |||||||||
| 376 | min([1e1 | 2e1 | 3e1]);;10 | |||||||||
| 377 | avg([1e2 | 2e2 | 3e2]);;200 | |||||||||
| 378 | contains([1e2 | 2e2 | 3e2] | 200);;true | ||||||||
| 379 | map([1e1 | 2e1 | 3e1] | # * 2);;[20 | 40 | 60] | ||||||
| 380 | filter([1e1 | 2e1 | 3e1 | 4e1] | # > 25);;[30 | 40] | ||||||
| 381 | # Scientific notation - edge cases | |||||||||||
| 382 | 1e+3;;1000 | |||||||||||
| 383 | 1e-0;;1 | |||||||||||
| 384 | 0e5;;0 | |||||||||||
| 385 | 1.0e2;;100 | |||||||||||
| 386 | 10e1;;100 | |||||||||||
| 387 | 0.1e3;;100 | |||||||||||
| 388 | 1.5e+2;;150 | |||||||||||
| 389 | 2e-1;;0.2 | |||||||||||
| 390 | # Scientific notation - mixed with regular numbers | |||||||||||
| 391 | 1e2 + 50.5;;150.5 | |||||||||||
| 392 | 1000 - 1e2;;900 | |||||||||||
| 393 | 15 * 1e2;;1500 | |||||||||||
| 394 | 1e3 / 2.5;;400 | |||||||||||
| 395 | # Scientific notation - complex expressions | |||||||||||
| 396 | (1e2 + 2e2) * 1e1;;3000 | |||||||||||
| 397 | 1e3 / (2e1 + 3e1);;20 | |||||||||||
| 398 | abs(-1e2);;100 | |||||||||||
| 399 | floor(1.23e2);;123 | |||||||||||
| 400 | ceil(1.23e2);;123 | |||||||||||
| 401 | round(1.234e2);;123 | |||||||||||
| 402 | # Scientific notation - in functions | |||||||||||
| 403 | 1e1 ^ 2;;100 | |||||||||||
| 404 | # Scientific notation - template strings | |||||||||||
| 405 | `Value: ${1e3}`;; 'Value: 1000' | |||||||||||
| 406 | `Scientific: ${2.5e2}`;; 'Scientific: 250' | |||||||||||
| 407 | `Negative: ${-1e2}`;; 'Negative: -100' | |||||||||||
| 408 | ### Assignment | |||||||||||
| 409 | # Basic assignment | |||||||||||
| 410 | # Property assignment | |||||||||||
| 411 | # Nested property assignment | |||||||||||
| 412 | # Multiple assignments | |||||||||||
| 413 | # Assignment with expressions | |||||||||||
| 414 | # Assignment with function calls | |||||||||||
| 415 | # Assignment with array operations | |||||||||||
| 416 | # Assignment with conditional expressions | |||||||||||
| 417 | # Assignment with object creation | |||||||||||
| 418 | # Assignment with template strings | |||||||||||
| 419 | # Assignment with return value |