This comment is reply for 3986 nobsun: 仮想機械(機械状態とインストラクションセ...(BFコンパイラー). Go to thread root.
[1..100]>>=pen #4288(2007/11/21 09:36 GMT) [ Haskell ] Rating1/1=1.00
高階関数を使ってみたい年頃なので高階関数使った版findpc を書いてみました。 findpc はループがネストしているとき '[' が来るごとに何度も呼ばれるのが ちょっともったいない気もします。 それと hClose oh しないとバッファが flush されませんでした。
1 2 3 4 5 6 7 8 9 10 11
-- import Maybe -- import Control.Monad -- -- where pc = findpc [] cs -- where pc = findpc cs findpc cs = fromMaybe (error "syntax error") $ msum $ snd $ mapAccumL f 0 cs where f 0 (p,']') = (0, Just (p+1)) f s (_,c) = (s+d, Nothing) where d = case c of; ']' -> (-1); '[' -> 1; _ -> 0
Rating1/1=1.00-0+
[ reply ]
[1..100]>>=pen
#4288()
[
Haskell
]
Rating1/1=1.00
Rating1/1=1.00-0+