4
我有點困惑與repA的封裝選擇功能:哈斯克爾惹巴---選擇功能比較混亂
select (\i -> True) (\i -> i) 10
給出結果
[0,1,2,3,4,5,6,7,8]
我想我是間0和10或0和9.爲什麼它在0和8之間?
repA的2.0.2.1
我有點困惑與repA的封裝選擇功能:哈斯克爾惹巴---選擇功能比較混亂
select (\i -> True) (\i -> i) 10
給出結果
[0,1,2,3,4,5,6,7,8]
我想我是間0和10或0和9.爲什麼它在0和8之間?
repA的2.0.2.1
看起來它產生一個長度len - 1
,這是在外殼9的陣列。這給你在[0-8]範圍內的索引。我同意文件可能更清楚。
如果你看看源,select
是在這些方面實現的selectChunkedP
:
-- | Select indices matching a predicate, in parallel.
-- The array is chunked up, with one chunk being given to each thread.
-- The number of elements in the result array depends on how many threads
-- you're running the program with.
selectChunkedP
:: forall a
. Unbox a
=> (Int -> Bool) --^See if this predicate matches.
-> (Int -> a) -- .. and apply fn to the matching index
-> Int -- Extent of indices to apply to predicate.
顯然,對於一個給定n
'指數的範圍' 包括所有指數x
這樣0 <= x < (n-1)
:
Prelude Data.Array.Repa> extent $ select (const True) id 10
Z :. 9