simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

compareText.md (1206B)


      1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
      2 
      3 # Function compareText
      4 
      5 Compare two strings lexically. Comparison is case sensitive.
      6 Returns 1 when x > y, -1 when x < y, and 0 when x == y.
      7 
      8 For matrices, the function is evaluated element wise.
      9 
     10 
     11 ## Syntax
     12 
     13 ```js
     14 math.compareText(x, y)
     15 ```
     16 
     17 ### Parameters
     18 
     19 Parameter | Type | Description
     20 --------- | ---- | -----------
     21 `x` | string &#124; Array &#124; DenseMatrix | First string to compare
     22 `y` | string &#124; Array &#124; DenseMatrix | Second string to compare
     23 
     24 ### Returns
     25 
     26 Type | Description
     27 ---- | -----------
     28 number &#124; Array &#124; DenseMatrix | Returns the result of the comparison: 1 when x > y, -1 when x < y, and 0 when x == y.
     29 
     30 
     31 ### Throws
     32 
     33 Type | Description
     34 ---- | -----------
     35 
     36 
     37 ## Examples
     38 
     39 ```js
     40 math.compareText('B', 'A')     // returns 1
     41 math.compareText('2', '10')    // returns 1
     42 math.compare('2', '10')        // returns -1
     43 math.compareNatural('2', '10') // returns -1
     44 
     45 math.compareText('B', ['A', 'B', 'C']) // returns [1, 0, -1]
     46 ```
     47 
     48 
     49 ## See also
     50 
     51 [equal](equal.md),
     52 [equalText](equalText.md),
     53 [compare](compare.md),
     54 [compareNatural](compareNatural.md)