USING: accessors alien.c-types arrays classes.struct fry kernel math math.vectors sequences ; IN: perceptron TUPLE: weighted-perceptron { perceptron array } { weight integer initial: 1 } ; : ( perception -- weighted-perceptron ) 1 weighted-perceptron boa ; : test-perceptron ( instance weighted-perceptron -- vote ) [ perceptron>> ] [ weight>> ] bi [ v. sgn ] dip * ; : predict ( weighted-perceptrons instance -- ? ) '[ _ test-perceptron + ] 0 swap reduce sgn 1 eq? ;