This commit is contained in:
Taylor 2025-01-14 02:50:26 -06:00
parent a82958feda
commit 5c786f5430
2 changed files with 4 additions and 2 deletions

View File

@ -78,5 +78,7 @@ intAdd state =
-- applyFuncState :: AtomicFuncTypes -> State -> State
-- this would change Gene to something like GeneModular above.
-- Wow, a one-liner for interpreting a paretheses-free genome...
-- Need to update this when adding parethetical blocks too.
interpretGenome :: State -> [(State -> State)] -> State
interpretGenome state = foldl (\acc f -> f acc) state

View File

@ -14,7 +14,7 @@ main = do
string = [StringGene "Hello", StringGene "Push"],
input = [Input $ IntGene 1, Input $ StringGene "Hi", Input $ BoolGene True, Input $ FloatGene 1.3]
}
-- This is an example of applynig one function (head exampleGenome) to the exampleState:
-- This is an example of applying one function (head exampleGenome produces intAdd) to the exampleState:
assert ([3, 3] == map unpackIntGene (int (head exampleGenome exampleState))) pure ()
-- This one-liner applies an entire genome to the starting state, and produces the final state:
-- This function applies an entire genome to the starting state, and produces the final state:
assert ([6] == (map unpackIntGene (int (interpretGenome exampleState exampleGenome)))) pure ()