我想在标准数组包中实现类似于有界数组的东西,但是使用了数组.
实现这一目标的好方法是什么?
这是我尝试过的,但必须有一个比检查边界的自定义函数中包装所有内容更好的方法:
import Data.Array.Repa
data C = A | F | L deriving (Eq,Enum,Ord,Bounded,Show)
data Ballot c = Ballot {
vote::Array U (Z :. Int) Int
} deriving Show
mkBallot::(Eq c ,Enum c,Ord c, Bounded c, Show c) => c -> Ballot c
mkBallot c = Ballot $ fromListUnboxed (Z :. max) (genSc c)
where
max = (fromEnum (maxBound `asTypeOf` c)) + 1
genSc::(Eq c,Enum c,Ord c,Bounded c,Show c) => c -> [Int]
genSc c = [ f x …Run Code Online (Sandbox Code Playgroud) 我遇到的问题与以下代码有关:
module Main(main) where
import qualified Media.Streaming.GStreamer as GS
import Data.Maybe
import System.IO
import System.Exit
import System.Glib.MainLoop as Glib
import System.Glib.Signals as Glib
import System.Glib.Properties as Glib
makeElement:: String ? String ? IO GS.Element
makeElement elementType elementName = do
element ? GS.elementFactoryMake elementType (Just elementName)
case element of
Just element' ? return element'
Nothing ? do
hPutStrLn stdout ("Cannot create element!")
hFlush stdout
exitFailure
player = do
GS.init
pipeline ? GS.pipelineNew "video-stream"
source ? makeElement "v4l2src" "video-source"
color ? makeElement …Run Code Online (Sandbox Code Playgroud) 假设
CompletableFuture<T> cf = CompletableFuture.completedFuture(...);
cf.thenApplyAsync(f)
.thenApplyAsync(g);
cf.thenApplyAsync(h);
Run Code Online (Sandbox Code Playgroud)
通过调用f和g的调用,我们得到了保证的顺序.什么^ h?我们是否得到任何guarentees ^ h将八方通后执行摹?
我试着把g睡觉以便测试这个,我总是看到h在g之后执行,但这不是证据.如果是这样的情况,h总是在g之后执行,我在哪里可以找到关于此的文档?我阅读了CompletionStage,ExecutorService和CompletableFuture文档,但我还没有找到任何信息可以让我得到关于排序的结论,例如在(g.f)的情况下不涉及链接.