如果我有一個列表和一個函數來計算分數,我可以計算argmax這樣: maxscore = 0; argmax = None
x = [3.49, 0.122, 293, 0.98] # Imagine a LARGE list.
for i in x:
# Maybe there're some other func() to calculate score
# For n
我是F#的新手,並且寫了一些簡單的算法來習慣這種語言,它需要argMax。標準庫是否具有用於搜索最大化函數的列表元素的功能?也就是說,如果有一個現有的功能,其行爲像這樣的: let argMax f xs =
let rec go a fa zs =
match zs with
| [] -> a
| z :: zs' ->
let fz =