Merge pull request #744 from HarrySarson/develop

Changed expressions/syntax in docs to represent the actual result of string operations.
This commit is contained in:
Jos de Jong 2016-11-08 22:01:43 +01:00 committed by GitHub
commit c4b95a1fa4

View File

@ -391,6 +391,11 @@ a string can be retrieved or replaced by using indexes. Strings can be converted
to a number using function `number`, and numbers can be converted to a string
using function `string`.
When setting the value of a character in a string, the character that has been
set is returned. Likewise, when a range of characters is set, that range of
characters is returned.
```js
var parser = math.parser();
@ -399,10 +404,11 @@ parser.eval('"hello"'); // String, "hello"
// string manipulation
parser.eval('a = concat("hello", " world")'); // String, "hello world"
parser.eval('size(a)'); // Number, 11
parser.eval('size(a)'); // Matrix [11]
parser.eval('a[1:5]'); // String, "hello"
parser.eval('a[1] = "H"'); // String, "Hello"
parser.eval('a[7:12] = "there!"'); // String, "Hello there!"
parser.eval('a[1] = "H"'); // String, "H"
parser.eval('a[7:12] = "there!"'); // String, "there!"
parser.eval('a'); // String, "Hello there!"
// string conversion
parser.eval('number("300")'); // Number, 300