diff options
Diffstat (limited to 'Master/texmf/asymptote/math.asy')
-rw-r--r-- | Master/texmf/asymptote/math.asy | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Master/texmf/asymptote/math.asy b/Master/texmf/asymptote/math.asy index ff267b955d7..a684307e5a5 100644 --- a/Master/texmf/asymptote/math.asy +++ b/Master/texmf/asymptote/math.asy @@ -144,6 +144,36 @@ int[][] segment(bool[] b) return segment; } +// If the sorted array a does not contain x, insert it sequentially, +// returning the index of x in the resulting array. +int unique(real[] a, real x) { + int i=search(a,x); + if(i == -1 || x != a[i]) { + ++i; + a.insert(i,x); + return i; + } + return i; +} + +int unique(string[] a, string x) { + int i=search(a,x); + if(i == -1 || x != a[i]) { + ++i; + a.insert(i,x); + return i; + } + return i; +} + +bool lexorder(pair a, pair b) { + return a.x < b.x || (a.x == b.x && a.y <= b.y); +} + +bool lexorder(triple a, triple b) { + return a.x < b.x || (a.x == b.x && (a.y < b.y || (a.y == b.y && a.z <= b.z))); +} + real[] zero(int n) { return sequence(new real(int) {return 0;},n); |