diff --git a/TODO.md b/TODO.md index 79efdc2..3ed2d12 100644 --- a/TODO.md +++ b/TODO.md @@ -7,7 +7,7 @@ - [X] Implement all functions as seen in the specification - [ ] Implement Linear Algebra functions as specified in the previous papers - [X] Add a function to sort a vector forward and backwards -- [ ] Disambiguate isEmpty and stackIsEmpty +- [X] Disambiguate isEmpty and stackIsEmpty - [X] Rename Logical to Bool - [X] Make int yank, shove, yankdup, and shovedup generic - [ ] Write hackage documentation for each function diff --git a/src/HushGP/Instructions.hs b/src/HushGP/Instructions.hs index 53772dc..b2b4a99 100644 --- a/src/HushGP/Instructions.hs +++ b/src/HushGP/Instructions.hs @@ -70,7 +70,7 @@ allIntInstructions = map StateFunc [ (instructionIntYank, "instructionIntYank"), (instructionIntYankDup, "instructionIntYankDup"), (instructionIntShove, "instructionIntShove"), - (instructionIntIsEmpty, "instructionIntIsEmpty"), + (instructionIntIsStackEmpty, "instructionIntIsStackEmpty"), (instructionIntFromChar, "instructionIntFromChar"), (instructionIntFromString, "instructionIntFromString"), (instructionIntDupItems, "instructionIntDupItems") @@ -103,7 +103,7 @@ allFloatInstructions = map StateFunc [ (instructionFloatYank, "instructionFloatYank"), (instructionFloatYankDup, "instructionFloatYankDup"), (instructionFloatShove, "instructionFloatShove"), - (instructionFloatIsEmpty, "instructionFloatIsEmpty"), + (instructionFloatIsStackEmpty, "instructionFloatIsStackEmpty"), (instructionFloatFromChar, "instructionFloatFromChar"), (instructionFloatFromString, "instructionFloatFromString"), (instructionFloatDupItems, "instructionFloatDupItems") @@ -130,7 +130,7 @@ allBoolInstructions = map StateFunc [ (instructionBoolYankDup, "instructionBoolYankDup"), (instructionBoolShove, "instructionBoolShove"), (instructionBoolShoveDup, "instructionBoolShoveDup"), - (instructionBoolIsEmpty, "instructionBoolIsEmpty"), + (instructionBoolIsStackEmpty, "instructionBoolIsStackEmpty"), (instructionBoolDupItems, "instructionBoolDupItems") ] @@ -159,7 +159,7 @@ allCharInstructions = map StateFunc [ (instructionCharYankDup, "instructionCharYankDup"), (instructionCharShove, "instructionCharShove"), (instructionCharShoveDup, "instructionCharShoveDup"), - (instructionCharIsEmpty, "instructionCharIsEmpty"), + (instructionCharIsStackEmpty, "instructionCharIsStackEmpty"), (instructionCharDupItems, "instructionCharDupItems") ] @@ -206,7 +206,7 @@ allCodeInstructions = map StateFunc [ (instructionCodeYankDup, "instructionCodeYankDup"), (instructionCodeShove, "instructionCodeShove"), (instructionCodeShoveDup, "instructionCodeShoveDup"), - (instructionCodeStackIsEmpty, "instructionCodeStackIsEmpty"), + (instructionCodeIsStackEmpty, "instructionCodeIsStackEmpty"), (instructionCodeFromBool, "instructionCodeFromBool"), (instructionCodeFromInt, "instructionCodeFromInt"), (instructionCodeFromChar, "instructionCodeFromChar"), @@ -240,7 +240,7 @@ allExecInstructions = map StateFunc [ (instructionExecYankDup, "instructionExecYankDup"), (instructionExecShove, "instructionExecShove"), (instructionExecShoveDup, "instructionExecShoveDup"), - (instructionExecIsEmpty, "instructionExecIsEmpty"), + (instructionExecIsStackEmpty, "instructionExecIsStackEmpty"), (instructionExecDoRange, "instructionExecDoRange"), (instructionExecDoCount, "instructionExecDoCount"), (instructionExecDoTimes, "instructionExecDoTimes"), @@ -312,7 +312,7 @@ allStringInstructions = map StateFunc [ (instructionStringYankDup, "instructionStringYankDup"), (instructionStringShove, "instructionStringShove"), (instructionStringShoveDup, "instructionStringShoveDup"), - (instructionStringIsEmpty, "instructionStringIsEmpty"), + (instructionStringIsStackEmpty, "instructionStringIsStackEmpty"), (instructionStringSort, "instructionStringSort"), (instructionStringSortReverse, "instructionStringSortReverse"), (instructionStringDupItems, "instructionStringDupItems"), @@ -354,7 +354,7 @@ allVectorIntInstructions = map StateFunc [ (instructionVectorIntYankDup, "instructionVectorIntYankDup"), (instructionVectorIntShove, "instructionVectorIntShove"), (instructionVectorIntShoveDup, "instructionVectorIntShoveDup"), - (instructionVectorIntStackIsEmpty, "instructionVectorIntStackIsEmpty"), + (instructionVectorIntIsStackEmpty, "instructionVectorIntIsStackEmpty"), (instructionVectorIntSort, "instructionVectorIntSort"), (instructionVectorIntSortReverse, "instructionVectorIntSortReverse"), (instructionVectorIntDupItems, "instructionVectorIntDupItems") @@ -395,7 +395,7 @@ allVectorFloatInstructions = map StateFunc [ (instructionVectorFloatYankDup, "instructionVectorFloatYankDup"), (instructionVectorFloatShove, "instructionVectorFloatShove"), (instructionVectorFloatShoveDup, "instructionVectorFloatShoveDup"), - (instructionVectorFloatStackIsEmpty, "instructionVectorFloatStackIsEmpty"), + (instructionVectorFloatIsStackEmpty, "instructionVectorFloatIsStackEmpty"), (instructionVectorFloatSort, "instructionVectorFloatSort"), (instructionVectorFloatSortReverse, "instructionVectorFloatSortReverse"), (instructionVectorFloatDupItems, "instructionVectorFloatDupItems") @@ -436,7 +436,7 @@ allVectorCharInstructions = map StateFunc [ (instructionVectorCharYankDup, "instructionVectorCharYankDup"), (instructionVectorCharShove, "instructionVectorCharShove"), (instructionVectorCharShoveDup, "instructionVectorCharShoveDup"), - (instructionVectorCharStackIsEmpty, "instructionVectorCharStackIsEmpty"), + (instructionVectorCharIsStackEmpty, "instructionVectorCharIsStackEmpty"), (instructionVectorCharSort, "instructionVectorCharSort"), (instructionVectorCharSortReverse, "instructionVectorCharSortReverse"), (instructionVectorCharDupItems, "instructionVectorCharDupItems") @@ -477,7 +477,7 @@ allVectorStringInstructions = map StateFunc [ (instructionVectorStringYankDup, "instructionVectorStringYankDup"), (instructionVectorStringShove, "instructionVectorStringShove"), (instructionVectorStringShoveDup, "instructionVectorStringShoveDup"), - (instructionVectorStringStackIsEmpty, "instructionVectorStringStackIsEmpty"), + (instructionVectorStringIsStackEmpty, "instructionVectorStringIsStackEmpty"), (instructionVectorStringSort, "instructionVectorStringSort"), (instructionVectorStringSortReverse, "instructionVectorStringSortReverse"), (instructionVectorStringDupItems, "instructionVectorStringDupItems") @@ -518,7 +518,7 @@ allVectorBoolInstructions = map StateFunc [ (instructionVectorBoolYankDup, "instructionVectorBoolYankDup"), (instructionVectorBoolShove, "instructionVectorBoolShove"), (instructionVectorBoolShoveDup, "instructionVectorBoolShoveDup"), - (instructionVectorBoolStackIsEmpty, "instructionVectorBoolStackIsEmpty"), + (instructionVectorBoolIsStackEmpty, "instructionVectorBoolIsStackEmpty"), (instructionVectorBoolSort, "instructionVectorBoolSort"), (instructionVectorBoolSortReverse, "instructionVectorBoolSortReverse"), (instructionVectorBoolDupItems, "instructionVectorBoolDupItems") diff --git a/src/HushGP/Instructions/BoolInstructions.hs b/src/HushGP/Instructions/BoolInstructions.hs index eff7e5a..0d65609 100644 --- a/src/HushGP/Instructions/BoolInstructions.hs +++ b/src/HushGP/Instructions/BoolInstructions.hs @@ -75,8 +75,8 @@ instructionBoolShove state = instructionShove state bool instructionBoolShoveDup :: State -> State instructionBoolShoveDup state = instructionShoveDup state bool -instructionBoolIsEmpty :: State -> State -instructionBoolIsEmpty state = instructionIsEmpty state bool +instructionBoolIsStackEmpty :: State -> State +instructionBoolIsStackEmpty state = instructionIsStackEmpty state bool instructionBoolDupItems :: State -> State instructionBoolDupItems = instructionDupItems bool diff --git a/src/HushGP/Instructions/CharInstructions.hs b/src/HushGP/Instructions/CharInstructions.hs index f2f4864..ba40350 100644 --- a/src/HushGP/Instructions/CharInstructions.hs +++ b/src/HushGP/Instructions/CharInstructions.hs @@ -79,8 +79,8 @@ instructionCharYank state = instructionYank state char instructionCharYankDup :: State -> State instructionCharYankDup state = instructionYankDup state char -instructionCharIsEmpty :: State -> State -instructionCharIsEmpty state = instructionIsEmpty state char +instructionCharIsStackEmpty :: State -> State +instructionCharIsStackEmpty state = instructionIsStackEmpty state char instructionCharShove :: State -> State instructionCharShove state = instructionShove state char diff --git a/src/HushGP/Instructions/CodeInstructions.hs b/src/HushGP/Instructions/CodeInstructions.hs index 2078992..b24b093 100644 --- a/src/HushGP/Instructions/CodeInstructions.hs +++ b/src/HushGP/Instructions/CodeInstructions.hs @@ -294,8 +294,8 @@ instructionCodeYank state = instructionYank state code instructionCodeYankDup :: State -> State instructionCodeYankDup state = instructionYankDup state code -instructionCodeStackIsEmpty :: State -> State -instructionCodeStackIsEmpty state = instructionIsEmpty state code +instructionCodeIsStackEmpty :: State -> State +instructionCodeIsStackEmpty state = instructionIsStackEmpty state code instructionCodeShove :: State -> State instructionCodeShove state = instructionShove state code diff --git a/src/HushGP/Instructions/ExecInstructions.hs b/src/HushGP/Instructions/ExecInstructions.hs index e4ced54..2234aea 100644 --- a/src/HushGP/Instructions/ExecInstructions.hs +++ b/src/HushGP/Instructions/ExecInstructions.hs @@ -47,8 +47,8 @@ instructionExecShove state = instructionShove state exec instructionExecShoveDup :: State -> State instructionExecShoveDup state = instructionShoveDup state exec -instructionExecIsEmpty :: State -> State -instructionExecIsEmpty state = instructionIsEmpty state exec +instructionExecIsStackEmpty :: State -> State +instructionExecIsStackEmpty state = instructionIsStackEmpty state exec execDoRange :: Gene execDoRange = StateFunc (instructionExecDoRange, "instructionExecDoRange") diff --git a/src/HushGP/Instructions/FloatInstructions.hs b/src/HushGP/Instructions/FloatInstructions.hs index 6b27896..a9984f2 100644 --- a/src/HushGP/Instructions/FloatInstructions.hs +++ b/src/HushGP/Instructions/FloatInstructions.hs @@ -112,8 +112,8 @@ instructionFloatShoveDup state = instructionShoveDup state float instructionFloatShove :: State -> State instructionFloatShove state = instructionShove state float -instructionFloatIsEmpty :: State -> State -instructionFloatIsEmpty state = instructionIsEmpty state float +instructionFloatIsStackEmpty :: State -> State +instructionFloatIsStackEmpty state = instructionIsStackEmpty state float instructionFloatSin :: State -> State instructionFloatSin state@(State {_float = f1 : fs}) = state {_float = sin f1 : fs} diff --git a/src/HushGP/Instructions/GenericInstructions.hs b/src/HushGP/Instructions/GenericInstructions.hs index cf6479c..1c2ca5d 100644 --- a/src/HushGP/Instructions/GenericInstructions.hs +++ b/src/HushGP/Instructions/GenericInstructions.hs @@ -96,8 +96,8 @@ instructionDup state accessor = instructionPop :: State -> Lens' State [a] -> State instructionPop state accessor = state & accessor .~ drop 1 (view accessor state) -instructionIsEmpty :: State -> Lens' State [a] -> State -instructionIsEmpty state@(State {_bool = bs}) accessor = state{_bool = null (view accessor state) : bs} +instructionIsStackEmpty :: State -> Lens' State [a] -> State +instructionIsStackEmpty state@(State {_bool = bs}) accessor = state{_bool = null (view accessor state) : bs} -- instructionPop :: State -> Lens' State [a] -> State -- instructionPop state accessor = if notEmptyStack state accessor then instructionPop state accessor else state diff --git a/src/HushGP/Instructions/IntInstructions.hs b/src/HushGP/Instructions/IntInstructions.hs index ea3877b..cf6019b 100644 --- a/src/HushGP/Instructions/IntInstructions.hs +++ b/src/HushGP/Instructions/IntInstructions.hs @@ -112,8 +112,8 @@ instructionIntShove state = instructionShove state int instructionIntShoveDup :: State -> State instructionIntShoveDup state = instructionShoveDup state int -instructionIntIsEmpty :: State -> State -instructionIntIsEmpty state = instructionIsEmpty state int +instructionIntIsStackEmpty :: State -> State +instructionIntIsStackEmpty state = instructionIsStackEmpty state int instructionIntDupItems :: State -> State instructionIntDupItems = instructionDupItems int diff --git a/src/HushGP/Instructions/StringInstructions.hs b/src/HushGP/Instructions/StringInstructions.hs index 59d492a..47eaed0 100644 --- a/src/HushGP/Instructions/StringInstructions.hs +++ b/src/HushGP/Instructions/StringInstructions.hs @@ -224,8 +224,8 @@ instructionStringYank state = instructionYank state string instructionStringYankDup :: State -> State instructionStringYankDup state = instructionYankDup state string -instructionStringIsEmpty :: State -> State -instructionStringIsEmpty state = instructionIsEmpty state string +instructionStringIsStackEmpty :: State -> State +instructionStringIsStackEmpty state = instructionIsStackEmpty state string instructionStringShove :: State -> State instructionStringShove state = instructionShove state string diff --git a/src/HushGP/Instructions/VectorBoolInstructions.hs b/src/HushGP/Instructions/VectorBoolInstructions.hs index 2a07ea2..a8ce980 100644 --- a/src/HushGP/Instructions/VectorBoolInstructions.hs +++ b/src/HushGP/Instructions/VectorBoolInstructions.hs @@ -96,8 +96,8 @@ instructionVectorBoolYank state = instructionYank state vectorBool instructionVectorBoolYankDup :: State -> State instructionVectorBoolYankDup state = instructionYankDup state vectorBool -instructionVectorBoolStackIsEmpty :: State -> State -instructionVectorBoolStackIsEmpty state = instructionIsEmpty state vectorBool +instructionVectorBoolIsStackEmpty :: State -> State +instructionVectorBoolIsStackEmpty state = instructionIsStackEmpty state vectorBool instructionVectorBoolShove :: State -> State instructionVectorBoolShove state = instructionShove state vectorBool diff --git a/src/HushGP/Instructions/VectorCharInstructions.hs b/src/HushGP/Instructions/VectorCharInstructions.hs index b84fef7..458cdda 100644 --- a/src/HushGP/Instructions/VectorCharInstructions.hs +++ b/src/HushGP/Instructions/VectorCharInstructions.hs @@ -96,8 +96,8 @@ instructionVectorCharYank state = instructionYank state vectorChar instructionVectorCharYankDup :: State -> State instructionVectorCharYankDup state = instructionYankDup state vectorChar -instructionVectorCharStackIsEmpty :: State -> State -instructionVectorCharStackIsEmpty state = instructionIsEmpty state vectorChar +instructionVectorCharIsStackEmpty :: State -> State +instructionVectorCharIsStackEmpty state = instructionIsStackEmpty state vectorChar instructionVectorCharShove :: State -> State instructionVectorCharShove state = instructionShove state vectorChar diff --git a/src/HushGP/Instructions/VectorFloatInstructions.hs b/src/HushGP/Instructions/VectorFloatInstructions.hs index da7e0de..424afea 100644 --- a/src/HushGP/Instructions/VectorFloatInstructions.hs +++ b/src/HushGP/Instructions/VectorFloatInstructions.hs @@ -96,8 +96,8 @@ instructionVectorFloatYank state = instructionYank state vectorFloat instructionVectorFloatYankDup :: State -> State instructionVectorFloatYankDup state = instructionYankDup state vectorFloat -instructionVectorFloatStackIsEmpty :: State -> State -instructionVectorFloatStackIsEmpty state = instructionIsEmpty state vectorFloat +instructionVectorFloatIsStackEmpty :: State -> State +instructionVectorFloatIsStackEmpty state = instructionIsStackEmpty state vectorFloat instructionVectorFloatShove :: State -> State instructionVectorFloatShove state = instructionShove state vectorFloat diff --git a/src/HushGP/Instructions/VectorIntInstructions.hs b/src/HushGP/Instructions/VectorIntInstructions.hs index 6ce893f..1f294cf 100644 --- a/src/HushGP/Instructions/VectorIntInstructions.hs +++ b/src/HushGP/Instructions/VectorIntInstructions.hs @@ -96,8 +96,8 @@ instructionVectorIntYank state = instructionYank state vectorChar instructionVectorIntYankDup :: State -> State instructionVectorIntYankDup state = instructionYankDup state vectorChar -instructionVectorIntStackIsEmpty :: State -> State -instructionVectorIntStackIsEmpty state = instructionIsEmpty state vectorChar +instructionVectorIntIsStackEmpty :: State -> State +instructionVectorIntIsStackEmpty state = instructionIsStackEmpty state vectorChar instructionVectorIntShove :: State -> State instructionVectorIntShove state = instructionShove state vectorChar diff --git a/src/HushGP/Instructions/VectorStringInstructions.hs b/src/HushGP/Instructions/VectorStringInstructions.hs index 0914d87..db68782 100644 --- a/src/HushGP/Instructions/VectorStringInstructions.hs +++ b/src/HushGP/Instructions/VectorStringInstructions.hs @@ -96,8 +96,8 @@ instructionVectorStringYank state = instructionYank state vectorString instructionVectorStringYankDup :: State -> State instructionVectorStringYankDup state = instructionYankDup state vectorString -instructionVectorStringStackIsEmpty :: State -> State -instructionVectorStringStackIsEmpty state = instructionIsEmpty state vectorString +instructionVectorStringIsStackEmpty :: State -> State +instructionVectorStringIsStackEmpty state = instructionIsStackEmpty state vectorString instructionVectorStringShove :: State -> State instructionVectorStringShove state = instructionShove state vectorString