User:Bd/BCT

From Esolang
Jump to navigation Jump to search
module BCT (bct) where

import Debug.Trace

-- | Execute a BCT program, returning its data tape.
--   Since no BCT program actually modifies any values in the data tape,
--   we treat the delete operation (False) as a return-value-to-environment
--   action.
--
--   The whole program is of course executed lazily.
bct :: [Bool] -> [Bool] -> [Bool]
bct p d = go (cycle p) d
    where
        go _ [] = []
        go (False:program) (h:t) = h:go program t
        go (True:next:program) dat@(h:_)
            | h
            = go program (dat ++ [next])
            | otherwise
            = go program dat

Bitwise Cyclic Tag