Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite92f4c6

Browse files
committed
doc
1 parent2855564 commite92f4c6

File tree

4 files changed

+893
-219
lines changed

4 files changed

+893
-219
lines changed

‎docs/compute-engine/50-math-json.md‎

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ A MathJSON expression is a combination of **numbers**, **symbols**, **strings**,
139139
```json example
140140
"x"
141141
"Pi"
142-
{"sym":"🍎"}
142+
"`🍎`"
143143
{"sym":"半径"}
144144
{"sym":"Pi","wikidata":"Q167"}
145145
```
@@ -189,9 +189,8 @@ A MathJSON **number** is either:
189189

190190
- an object literal with a`"num"` key
191191
- a JSON number
192-
- a JSON string starting with`+`,`-` or the digits`0`-`9`. Using a string
193-
is useful to represent numbers with a higher precision or greater range than
194-
JSON numbers.
192+
- a JSON string literal. Using a string is useful to represent numbers with a
193+
higher precision or greater range than JSON numbers.
195194

196195
###Numbers as Object Literals
197196

@@ -286,14 +285,15 @@ The numeric values below may not be represented as JSON number literals:
286285
###Numbers as String Literals
287286

288287
An alternate representation of a**number** with no extra metadata is as a
289-
stringfollowing theformat described above.
288+
stringmatching theRegex pattern`/^[+-]?(0|[1-9][0-9]*)(\.[0-9]+)?(\([0-9]+\))?([eE][+-]?[0-9]+)?$/`.
290289

291290
This allows for a shorthand representation of numbers with a higher precision or
292291
greater range than JSON numbers.
293292

294293
```json example
295294
"3.14159265358979323846264338327950288419716"
296-
"+Infinity"
295+
"-1.7976931348623157e+308"
296+
"5.7(317)e-2"
297297
```
298298

299299
##Strings
@@ -303,7 +303,16 @@ A MathJSON **string** is either:
303303
- an object literal with a`"str"` key
304304
- a[JSON string](https://tools.ietf.org/html/rfc7159#section-7) that starts and
305305
ends with**U+0027`'` APOSTROPHE**.
306-
- a JSON string that is not an identifier shorthand or a number, that is a
306+
- a JSON string that is not a symbol shorthand or a number shorthand.
307+
308+
That is:
309+
310+
-`"Hello World"` is a string (it includes a space character which is not allowed in symbols)
311+
-`"HelloWorld"` is a symbol (it does not include a space character)
312+
-`"3.14"` is a number (it is a valid JSON number)
313+
-`"'3.14'"` is a string (it is wrapped with single quotes)
314+
-`"🍎"` is a string
315+
-``"`🍎`"`` is a symbol shorthand (it is wrapped with backticks)
307316

308317
MathJSON strings must be[well formed JSON strings](https://tc39.es/proposal-well-formed-stringify/), which means they must escape surrogate codepoints`U+D800` to`U+DFFF`, control characters`U+0000` to`U+001F`, and the characters**U+0022`'` QUOTATION MARK** and**U+005C`\` REVERSE SOLIDUS** (backslash).
309318

@@ -450,20 +459,25 @@ A MathJSON **symbol** is either:
450459
Symbols are JSON strings that represent the names of symbols, variables,
451460
constants, wildcards and functions.
452461

462+
For a JSON string literal to be interpreted as a symbol, it must either
463+
begin and start with a`` ``` (`U+0060` GRAVE ACCENT) or be a
464+
string matching the Regex pattern`/^[a-zA-Z_][a-zA-Z0-9_]*$/`.
465+
466+
453467
Before they are used, JSON escape sequences (such as`\u` sequences,`\\`, etc.)
454468
are decoded.
455469

456470
The symbols are then normalized to the
457471
[Unicode Normalization Form C (NFC)](https://unicode.org/reports/tr15/). They
458472
are stored internally and compared using the Unicode NFC.
459473

460-
For example, these fourJSON strings represent the same symbol:
474+
For example, these fourobject literals represent the same symbol:
461475

462-
-`"Å"`
463-
-`"A\u030a"`**U+0041`A‌` LATIN CAPITAL LETTER** +**U+030A` ̊` COMBINING RING
476+
-`{ "sym": "Å" }`
477+
-`{ "sym": "A\u030a" }`**U+0041`A‌` LATIN CAPITAL LETTER** +**U+030A` ̊` COMBINING RING
464478
ABOVE**
465-
-`"\u00c5"`**U+00C5`Å` LATIN CAPITAL LETTER A WITH RING ABOVE**
466-
-`"\u0041\u030a"`**U+0041`A‌` LATIN CAPITAL LETTER A** +**U+030A` ̊` COMBINING RING
479+
-`{ "sym": "\u00c5" }`**U+00C5`Å` LATIN CAPITAL LETTER A WITH RING ABOVE**
480+
-`{ "sym": "\u0041\u030a" }`**U+0041`A‌` LATIN CAPITAL LETTER A** +**U+030A` ̊` COMBINING RING
467481
ABOVE**
468482

469483
Symbols conform to a profile of

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp