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]
impl<V, R, F> SimpleEvaluator<V, R, F> where
V: Clone + PartialEq + Send + Sync,
R: Clone + Sync,
F: Fn(&str, &[V]) -> Result<V, R>,
pub fn of(f: F) -> Self
[src]
pub fn of(f: F) -> Self
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]
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,
type Space = V
The value space of a domain. The inputs of every primitive and the result of every evaluation must be of this type. Read more
type Error = R
If evaluation should fail, this would hold an appropriate error.
fn evaluate(
&self,
primitive: &str,
inps: &[Self::Space]
) -> Result<Self::Space, Self::Error>
[src]
fn evaluate(
&self,
primitive: &str,
inps: &[Self::Space]
) -> Result<Self::Space, Self::Error>
fn lift(&self, _f: LiftedFunction<Self::Space, Self>) -> Result<Self::Space, ()>
[src]
fn lift(&self, _f: LiftedFunction<Self::Space, Self>) -> Result<Self::Space, ()>
Auto Trait Implementations
impl<V, R, F> Send for SimpleEvaluator<V, R, F> where
F: Send,
R: Send,
V: Send,
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,
impl<V, R, F> Sync for SimpleEvaluator<V, R, F> where
F: Sync,
R: Sync,
V: Sync,