comments
This commit is contained in:
parent
a82958feda
commit
5c786f5430
@ -78,5 +78,7 @@ intAdd state =
|
|||||||
-- applyFuncState :: AtomicFuncTypes -> State -> State
|
-- applyFuncState :: AtomicFuncTypes -> State -> State
|
||||||
-- this would change Gene to something like GeneModular above.
|
-- 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 -> [(State -> State)] -> State
|
||||||
interpretGenome state = foldl (\acc f -> f acc) state
|
interpretGenome state = foldl (\acc f -> f acc) state
|
||||||
|
@ -14,7 +14,7 @@ main = do
|
|||||||
string = [StringGene "Hello", StringGene "Push"],
|
string = [StringGene "Hello", StringGene "Push"],
|
||||||
input = [Input $ IntGene 1, Input $ StringGene "Hi", Input $ BoolGene True, Input $ FloatGene 1.3]
|
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 ()
|
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 ()
|
assert ([6] == (map unpackIntGene (int (interpretGenome exampleState exampleGenome)))) pure ()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user