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