相关疑难解决方法(0)

Golang相当于Python的列表理解

我正在玩Go,但我很难做其他语言非常简单的事情.

我想重现一个类似的语法:

array = [a for a in anotherArray  if (some condition)]
Run Code Online (Sandbox Code Playgroud)

Go的优雅方式是什么?我真的很想简化我的代码,尤其是在使用数组上的函数时.例如:

min = min(abs(a[i], b[j]) for i in range(n)
                          for j in range(i, n))
Run Code Online (Sandbox Code Playgroud)

非常感谢

python go

23
推荐指数
1
解决办法
1万
查看次数

标签 统计

go ×1

python ×1