在枫树中,如何创建一系列交替变量?
我是 Maple 的新手,我想创建以下列表:
U__N := u__1[0], u__2[0], u__1[1], u__2[1], u__1[2], u__2[2], u__1[3], u__2[3], u__1[4], u__2[4], u__1[5], u__2[5]
我想出了以下两个选项。 知识
对于两者,我都缺乏最后一步选项1的
U__N := seq([u__1[k], u__2[k]], k = 0 .. 5)
,它给了我一个嵌套的列表:u__n:= [u__1 [0],u__2 [0]],[u__1 [1],U__2 [1],[1],[ U__1 [2],U__2 [2]],[U__1 [3],U__2 [3]],[U__1 [4],U__2 [4]],[U__1 [5],U__2 [5]]
> 。但是,现在我不知道如何“ nested”嵌套列表。
选项2:
创建两个
U__N2 := seq(u__2[k], k = 0 .. 5 - 1)
返回U__N1:= U__1 [0],U__1 [1],U__1 [2],U__1 [3],U__1 [3],U__1 [4]
U__N2 := seq(u__2[k], k = 0 .. 5 - 1)
返回u__n2: = U__2 [0],U__2 [1],U__2 [2],U__2 [3],U__2 [4]
。 现在,我想加入/组合这两个列表。
您对这两个选项之一或替代解决方案有任何建议吗?
I'm quite new to Maple and I would like to create the following list:
U__N := u__1[0], u__2[0], u__1[1], u__2[1], u__1[2], u__2[2], u__1[3], u__2[3], u__1[4], u__2[4], u__1[5], u__2[5]
I came up with the following two options. For both I lack the knowledge for the last step
Option 1
U__N := seq([u__1[k], u__2[k]], k = 0 .. 5)
which gives me a nested list: U__N := [u__1[0], u__2[0]], [u__1[1], u__2[1]], [u__1[2], u__2[2]], [u__1[3], u__2[3]], [u__1[4], u__2[4]], [u__1[5], u__2[5]]
. However, now I do not know how to "un-nest" the nested list.
Option 2:
Create two separate lists
U__N2 := seq(u__2[k], k = 0 .. 5 - 1)
which returns U__N1 := u__1[0], u__1[1], u__1[2], u__1[3], u__1[4]
U__N2 := seq(u__2[k], k = 0 .. 5 - 1)
which returns U__N2 := u__2[0], u__2[1], u__2[2], u__2[3], u__2[4]
.
Now I would like to concatenate/combine these two lists alternatively.
Do you have any suggestions for one of these two options or an alternative solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 flatten
using Flatten gave me the desired solution
我宁愿创建配对部分,然后直接利用这些部分,而不是形成整个名单列表和
flatten
it。seq
命令的特殊评估规则允许其第一个参数直到之后才能评估k
获得具体数值。这允许您使用
op
命令调整第一个方法并提取成对内部列表的操作数。中的tailting
的作用类似于[]
[...] [] []op([...])
。I would prefer to create the pair-wise portions and then utilize those directly, than to form the whole list-of-lists and
Flatten
it.The special-evaluation rules of the
seq
command allows for its first argument to not be evaluated until afterk
attains concrete numeric values.This allow you to adjust your first method and extract the operands of the pair-wise inner lists, using the
op
command.The trailing
[]
in[...][]
acts likeop([...])
.