我试图将使用itertools
库的Python函数转换为VB.Net:
permutations = itertools.product('ab', repeat=3)
上述函数返回所有排列:
[['a','a','a'],
['a','a','b'],
['a','b','a'],
['a','b','b'],
['b','a','a'],
['b','a','b'],
['b','b','a'],
['b','b','b']]
在VB.Net中有一个很好的干净方法吗?
答案 0 :(得分:1)
如果我没有弄错的话,你的问题的答案。 - https://stackoverflow.com/a/21090635/2319909
答案 1 :(得分:0)
我最终将python itertools.product
函数转换为vb.net:
Function Permute (chars As List (Of Char), len As Integer) As List (Of List (Of Char))
Dim pools As New List (Of List (Of Char))
Dim result As New List (Of List (Of Char)) From {New List (Of Char)}
For i = 0 To len - 1
pools.Add (chars)
Next
For Each pool As List (Of Char) In pools
Dim result2 As New List (Of List (Of Char))
For Each x In result
For Each y In pool
Dim temp As New List (Of Char)(x)
temp.Add (y)
result2.Add (temp)
Next
Next
result = New List (Of List (Of Char))(result2)
Next
Return result
End Function