more instructions
This commit is contained in:
parent
452e7a2b49
commit
de8fedb5d1
@ -108,3 +108,18 @@ instructionShoveDup state@(State {_int = []}) _ = state
|
|||||||
-- also also not int generic
|
-- also also not int generic
|
||||||
instructionShove :: State -> Lens' State [a] -> State
|
instructionShove :: State -> Lens' State [a] -> State
|
||||||
instructionShove state accessor = instructionShoveDup state accessor & accessor .~ drop 1 (view accessor (instructionShoveDup state accessor))
|
instructionShove state accessor = instructionShoveDup state accessor & accessor .~ drop 1 (view accessor (instructionShoveDup state accessor))
|
||||||
|
|
||||||
|
-- not char generic
|
||||||
|
instructionConcat :: Semigroup a => State -> Lens' State [a] -> State
|
||||||
|
instructionConcat state accessor =
|
||||||
|
if (length . take 2 $ view accessor state) == 2
|
||||||
|
then droppedState & accessor .~ (head (view accessor state) <> view accessor state !! 1) : view accessor droppedState
|
||||||
|
-- then undefined
|
||||||
|
else state
|
||||||
|
where
|
||||||
|
droppedState :: State
|
||||||
|
droppedState = state & accessor .~ drop 2 (view accessor state)
|
||||||
|
|
||||||
|
-- evolve fodder???????????
|
||||||
|
instructionNoOp :: State -> State
|
||||||
|
instructionNoOp state = state
|
||||||
|
17
src/Instructions/StringInstructions.hs
Normal file
17
src/Instructions/StringInstructions.hs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
module Instructions.StringInstructions where
|
||||||
|
|
||||||
|
import State
|
||||||
|
import Instructions.GenericInstructions
|
||||||
|
|
||||||
|
combineString :: String -> (String, String) -> String
|
||||||
|
combineString toInsert (front, back) = front <> toInsert <> back
|
||||||
|
|
||||||
|
instructionStringConcat :: State -> State
|
||||||
|
instructionStringConcat state = instructionConcat state string
|
||||||
|
|
||||||
|
instructionStringSwap :: State -> State
|
||||||
|
instructionStringSwap state = instructionSwap state string
|
||||||
|
|
||||||
|
instructionStringInsertString :: State -> State
|
||||||
|
instructionStringInsertString state@(State{_string = s1 : s2 : ss, _int = i1 : is}) = state {_string = combineString s2 (splitAt i1 s1) : ss, _int = is}
|
||||||
|
instructionStringInsertString state = state
|
Loading…
x
Reference in New Issue
Block a user