Пример #1
0
 public function __construct(Formlet $formlet, FunctionValue $transform_builder, FunctionValue $transform_collector)
 {
     C::guardHasArity($transform_builder, 1);
     C::guardHasArity($transform_collector, 1);
     $this->_formlet = $formlet;
     $this->_transform_builder = $transform_builder;
     $this->_transform_collector = $transform_collector;
 }
Пример #2
0
 public function __construct(Collector $collector, FunctionValue $wrapper)
 {
     C::guardHasArity($wrapper, 2);
     if ($collector->isNullaryCollector()) {
         throw new Exception("It makes no sense to wrap around a nullary collector.");
     }
     $this->_collector = $collector;
     $this->_wrapper = $wrapper;
 }
Пример #3
0
 public final function satisfies(FunctionValue $predicate, $error)
 {
     C::guardIsString($error);
     C::guardHasArity($predicate, 1);
     return $this->map(V::fn_w(function ($value) use($predicate, $error) {
         if (!$predicate->apply($value)->get()) {
             return V::error($error, $value->origin());
         }
         return $value;
     }));
 }
Пример #4
0
 /**
  * Make a depth first search.
  * Performs $transformation on every node that matches $predicate. If 
  * $transformation returns null, search will go on, if it returns a 
  * value, search will stop and return the value.
  */
 public function depthFirst(FunctionValue $predicate, FunctionValue $transformation)
 {
     C::guardHasArity($predicate, 1);
     C::guardHasArity($transformation, 1);
     if ($predicate->apply(V::val($this))->get()) {
         $res = $transformation->apply(V::val($this))->get();
         if ($res !== null) {
             return $res;
         }
     }
     return $this->goDepth($predicate, $transformation);
 }
Пример #5
0
 public function __construct(Builder $builder, FunctionValue $transformation)
 {
     C::guardHasArity($transformation, 2);
     $this->_builder = $builder;
     $this->_transformation = $transformation;
 }