diff options
author | Karl Berry <karl@freefriends.org> | 2013-05-18 22:47:34 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-05-18 22:47:34 +0000 |
commit | 8da523330e61ea8e7b930c09cecaddec0b3a72a0 (patch) | |
tree | 07f156e733c33e3f416fa3de086bec250c693a25 /Master/texmf-dist/asymptote/math.asy | |
parent | baff4255d94a765ab41d84c89ea23e44151770ee (diff) |
asymptote 2.22
git-svn-id: svn://tug.org/texlive/trunk@30566 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/asymptote/math.asy')
-rw-r--r-- | Master/texmf-dist/asymptote/math.asy | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/Master/texmf-dist/asymptote/math.asy b/Master/texmf-dist/asymptote/math.asy index 77c0664895f..46d663d3181 100644 --- a/Master/texmf-dist/asymptote/math.asy +++ b/Master/texmf-dist/asymptote/math.asy @@ -149,8 +149,9 @@ bool increasing(real[] a, bool strict=false) return all(b); } -// Return the indices of consecutive true-element segments of bool[] b. -int[][] segment(bool[] b) +// Return the first and last indices of consecutive true-element segments +// of bool[] b. +int[][] segmentlimits(bool[] b) { int[][] segment; bool[] n=copy(b); @@ -159,15 +160,24 @@ int[][] segment(bool[] b) int[] edge=(b != n) ? sequence(1,b.length) : null; edge.insert(0,0); int stop=edge[0]; - for(int i=0; i < edge.length-1;) { + for(int i=1; i < edge.length; ++i) { int start=stop; - stop=edge[++i]; + stop=edge[i]; if(b[start]) - segment.push(sequence(start,stop-1)); + segment.push(new int[] {start,stop-1}); } return segment; } +// Return the indices of consecutive true-element segments of bool[] b. +int[][] segment(bool[] b) +{ + int[][] S=segmentlimits(b); + return sequence(new int[](int i) { + return sequence(S[i][0],S[i][1]); + },S[0].length); +} + // 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) { |