creatur-4.1.7: Framework for artificial life experiments.

Portabilityportable
Stabilityexperimental
Maintaineramy@nualeargais.ie
Safe HaskellNone

ALife.Creatur.Genetics.Code

Contents

Description

Lookup table for encoding genes.

Synopsis

Coding schemes

data Code a b Source

An encoding scheme.

Constructors

Code 

Fields

cSize :: Int
 
cTable :: [(a, [b])]
 

Instances

(Show a, Show b) => Show (Code a b) 

Encoding and decoding

encode :: Eq a => Code a b -> a -> Maybe [b]Source

Encodes a value as a sequence of letters in the code alphabet.

encodeNext :: Eq a => Code a b -> a -> [b] -> [b]Source

Encodes a value and append it to the sequence provided. If the value cannot be encoded, the sequence is returned unmodified.

decode :: Eq b => Code a b -> [b] -> Maybe aSource

Returns the value corresponding to a sequence of letters in the code alphabet.

decodeNext :: Eq b => Code a b -> [b] -> Maybe (a, [b])Source

Decodes a value from a sequence, and returns the value and the unused portion of the sequence.