在枫树中,如何创建一系列交替变量?

发布于 2025-01-25 21:57:25 字数 866 浏览 5 评论 0原文

我是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梨涡 2025-02-01 21:57:26

使用 flatten

using Flatten gave me the desired solution

沐歌 2025-02-01 21:57:25

我宁愿创建配对部分,然后直接利用这些部分,而不是形成整个名单列表和flatten it。

seq命令的特殊评估规则允许其第一个参数直到之后才能评估 k获得具体数值。

这允许您使用op命令调整第一个方法并提取成对内部列表的操作数。

seq(op([u__1[k], u__2[k]]), k = 0 .. 5);

   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]

seq([u__1[k], u__2[k]][], k = 0 .. 5);

   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]

中的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 after k 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.

seq(op([u__1[k], u__2[k]]), k = 0 .. 5);

   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]

seq([u__1[k], u__2[k]][], k = 0 .. 5);

   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]

The trailing [] in [...][] acts like op([...]).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文