Struct programinduction::lambda::SimpleEvaluator[][src]

pub struct SimpleEvaluator<V, R, F>(_, _);

An Evaluator defined solely by a function.

Use of to create one. Incapable of dealing with first-class functions.

Methods

impl<V, R, F> SimpleEvaluator<V, R, F> where
    V: Clone + PartialEq + Send + Sync,
    R: Clone + Sync,
    F: Fn(&str, &[V]) -> Result<V, R>, 
[src]

Create a SimpleEvaluator out of a function that takes a primitive name and a list of arguments.

Examples

use programinduction::lambda::SimpleEvaluator;

fn evaluate(primitive: &str, inp: &[bool]) -> Result<bool, ()> {
    match primitive {
        "nand" => Ok(!(inp[0] & inp[1])),
        _ => unreachable!(),
    }
}

let eval = SimpleEvaluator::of(evaluate);

Trait Implementations

impl<V, R, F> Evaluator for SimpleEvaluator<V, R, F> where
    V: Clone + PartialEq + Send + Sync,
    R: Clone + Sync,
    F: Fn(&str, &[V]) -> Result<V, R> + Sync
[src]

The value space of a domain. The inputs of every primitive and the result of every evaluation must be of this type. Read more

If evaluation should fail, this would hold an appropriate error.

Auto Trait Implementations

impl<V, R, F> Send for SimpleEvaluator<V, R, F> where
    F: Send,
    R: Send,
    V: Send

impl<V, R, F> Sync for SimpleEvaluator<V, R, F> where
    F: Sync,
    R: Sync,
    V: Sync