Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| documentation:language_reference:objects:matrix:operations:eq [2024/12/12 14:27] – created Maurits W. Haverkort | documentation:language_reference:objects:matrix:operations:eq [2025/11/20 04:20] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ### | ### | ||
| - | alligned paragraph text | + | We can compare two matrices with the == operator. One needs to be careful though as matrices stored as tables + meta methods are always different from matrices stored as user date. Comparison is done element by element. |
| ### | ### | ||
| ===== Example ===== | ===== Example ===== | ||
| - | |||
| - | ### | ||
| - | description text | ||
| - | ### | ||
| ==== Input ==== | ==== Input ==== | ||
| <code Quanty Example.Quanty> | <code Quanty Example.Quanty> | ||
| - | -- some example code | + | A = Matrix.New({{1, |
| + | B = Matrix.New({{1, | ||
| + | C = Matrix.New({{5, | ||
| + | |||
| + | D = {{1, | ||
| + | setmetatable(D, | ||
| + | E = {{1, | ||
| + | setmetatable(E, | ||
| + | F = {{5, | ||
| + | setmetatable(F, | ||
| + | |||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| </ | </ | ||
| ==== Result ==== | ==== Result ==== | ||
| <file Quanty_Output> | <file Quanty_Output> | ||
| - | text produced | + | Matrix |
| + | A==B true | ||
| + | A==C false | ||
| + | Matrix as table with metadata comparison | ||
| + | D==E true | ||
| + | D==F false | ||
| + | but WARNING WARNING, userdata are never equal to tables with metadata | ||
| + | A==D false | ||
| </ | </ | ||
| ===== Table of contents ===== | ===== Table of contents ===== | ||
| - | {{indexmenu> | + | {{indexmenu> |