erlang - [ ... || 是什么意思? ... <- ...] 在这段代码中做什么?

标签 erlang

我再次需要你的帮助,我正在尝试理解这段 erlang 代码。

Line="This is cool".
Lines = [Line || _Count <- lists:seq(1,5)].

输出为

["This is cool","This is cool","This is cool","This is cool","This is cool"]

我不明白打印所需次数背后的逻辑。 Line || 是什么意思? _***** 是什么意思?

最佳答案

由于Line的值在列表推导式的右侧没有改变,所以每个元素的值是相同的,即Line的值。

列表理解的右侧只是确定元素的数量。

关于erlang - [ ... || 是什么意思? ... <- ...] 在这段代码中做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15526373/

相关文章:

architecture - Erlang OTP应用程序设计

erlang - 为什么shell中这两个erlang表达式序列的输出不同?

windows - 在 Windows 7 机器上安装后 RabbitMQ 服务器没有启动

erlang - Elixir 调用 :io_lib. fread

埃尔兰;在通用测试开始时启动应用程序

erlang - 在 Elixir 中,节点和进程有什么区别?

erlang - 我如何知道 elixir 的 CPU 中的内核数量?

Erlang Hello World 使用 Bazel 作为构建系统

mysql - 如何使用 erlang-mysql-driver 连接到我的数据库?

build - Erlang 的标准构建工具是什么?