如何用索引上的条件定义序列?
我需要处理 i
我尝试按照下面的屏幕截图进行操作,但它仍然保留 j
I need to deal with the sequence a[i][j] with i<j, but I do not know if there exists a command to do this.
I am trying to manipulate as in the screenshot below, but it is still keeping the cases j<i.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
生成完整集合(
i=1..n
和j=1..n
)然后删除不需要的部分的方法效率低下。这里有两种更有效的方法(以及使用
minus
的方法,但固定为使用 double-seq)。The approach of generating the full set (
i=1..n
andj=1..n
) and then removing the unwanted portion is unnecessarily inefficient.Here are two more efficient ways (as well as that way using
minus
, but fixed to use the double-seq).对于这个问题,我会使用@acer的答案中的第一种方法。但以防万一,如果索引的条件有点复杂,以至于您无法快速想出一个简单的公式,可以用来在该答案的第一种方法中创建索引,或者写为集合减去二索引设置等,然后您可以使用 Maple 中的
select
命令以及作为布尔函数的原始条件。以下是它在您的情况下的工作原理。您知道如何无限制地生成所有
[i, j]
,即上面select
命令的第二个参数。你对他们的条件是;如果你拿起一对,它的第一个元素小于它的第二个元素。所以我们在上面写了select
的第一个参数,它是一个布尔函数,对于每一对,如果条件成立,则返回true
,否则返回false
。select
命令选取其第二个参数的元素,这些元素在第一个参数的函数下给出true
。现在您已经有了索引列表,您可以使用单个seq
来使用它们。这是输出的屏幕截图。

For this question, I would go with the first method in @acer's answer. But just in case, if the condition on the indices were a bit complicated such that you could not quickly come up with an easy formulation that can be used to create your indices in the 1st method in that answer or to write as set minus of two indices set etc. then you can use the
select
command in Maple and the original condition that you have as a boolean function. Here is how it would work in your case.You knew how to generate all
[i, j]
's with no restriction, the second argument of theselect
command above. And your condition on them is; if you pick up a pair, its 1st element being less than its 2nd element. So we wrote the 1st argument ofselect
above which is a boolean function, for each pair, if the condition holds, it returnstrue
otherwise returnsfalse
. Theselect
command picks up the elements of its 2nd arguments that givetrue
under the function in its 1st argument. Now that you have the list of indices, you can use a singleseq
to use them.Here is the screenshot of the outputs.
