TUPLE: function-finder < ga ; : ( -- obj ) function-finder new 50 >>population-size { swap over drop nip dup nop 1 2 3 4 5 6 sgn min max neg mod rem + - * / -1 -2 -1 -3 -4 } >>possible-genes 10 >>crossover-rate 30 >>mutation-rate 5 >>genome-length { { 1 2 3 4 } } >>training-input-stack { { 2 4 6 8 } } >>training-output-stack init-population evaluate-population ; M: function-finder genome-stack-formalizer drop [ map ] curry ; M: function-finder compare-output-to-awaited-result training-output-stack>> 2dup [ length 1 = ] bi@ and [ [ first ] bi@ 2dup [ length ] bi@ = [ [ - abs ] 2map sum ] [ 2drop 1000 ] if ] [ 2drop f ] if ; M: function-finder genome-decoder drop sequence>> >quotation ;