Example #1
0
 public function testConsReturnsNewSequenceWithItemAsFirst()
 {
     $cons1 = new Cons("foo");
     $cons2 = $cons1->cons("bar");
     $this->assertEquals(2, $cons2->count());
     $this->assertEquals("bar", $cons2->first());
 }
Example #2
0
 public function test_assoc()
 {
     $name = new Cons(":name", "Teto Kasane");
     $age = new Cons(":age", 31);
     $alist = new Cons($name, new Cons($age, null));
     $undefined = "'undefined";
     $this->assertSame($name, $alist->assoc(":name", $undefined));
     $this->assertSame($age, $alist->assoc(":age", $undefined));
     $this->assertSame($undefined, $alist->assoc(":author", $undefined));
     $this->assertSame($name, $alist->rassoc("Teto Kasane", $undefined));
     $this->assertSame($age, $alist->rassoc(31, $undefined));
     $this->assertSame($undefined, $alist->rassoc("Miku Hatsune", $undefined));
 }
Example #3
0
function SCM_cons($s)
{
    $x = $s->car;
    $y = $s->cdr->car;
    $cons = Cons::new_instance();
    $cons->set_car($x);
    $cons->add_cdr($y);
    return $cons;
}
Example #4
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Cons the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Cons::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #5
0
{
    public function evaluate($env)
    {
        return $this;
    }
    public function apply($args)
    {
        $prod = $args->foldLeft(1, function ($res, $exp) {
            if ($exp->isInt()) {
                return $res * $exp->toInt();
            } else {
                throw new InvalidArgumentException("*: argument is not a valid integer");
            }
        });
        return new ExpInt($prod);
    }
    public function __toString()
    {
        return "*";
    }
}
$env = new Environment();
$two = new ExpInt(2);
$seven = new ExpInt(7);
$five = new ExpInt(5);
$plus = new Plus();
$mult = new Mult();
$exp1 = new Cons($plus, new Cons($two, new Cons($seven, new Cons($five, new Nil()))));
$exp2 = new Cons($mult, new Cons($two, new Cons($exp1, new Cons($five, new Nil()))));
echo "The evaluation of the Lisp expression: " . $exp2 . "\n";
echo "yields the value: " . $exp2->evaluate($env) . "\n";
 public function actionPdf($idCodt, $fecha)
 {
     $modelCons = Cons::model();
     $model = new Cons();
     $this->render('report1', array('model' => $model, 'idCod' => $idCodt, 'fecha' => $fecha, 'excel' => 0, 'pdf' => $idCodt));
 }
Example #7
0
 /**
  * リスト評価
  */
 private static function evlis($args, $env)
 {
     $proc = $args;
     $cons = Cons::new_instance();
     while ($proc) {
         $cons->add_cdr(self::evaluate($proc->car, $env));
         $proc = $proc->cdr;
     }
     return $cons->cdr;
 }
Example #8
0
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'cons-form',
	'enableAjaxValidation'=>FALSE,
)); ?>

	<p class="note">Campos con <span class="required">*</span> son requeridos.</p>

	<?php echo $form->errorSummary($model); ?>

        <div class="row">
		<?php // echo $form->labelEx($model,'Registro',array('TYPE'=>"hidden")); ?>
		<?php $lIDS = Cons::model()->getLastId();
               echo $form->textField($model,'Registro',array('readonly'=>'readonly','hidden'=>'true' ,'value'=>$lIDS+1));  ?>
		<?php echo $form->error($model,'Registro'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'FECHA'); ?>
                <?php
                /*
                 * Esta funcion llama al componente zii.widgets.jui.CJuiDatePicker
                 * Que depliega un calendario en la interface de usuario
                 */
                $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                    'language'=>'es',
                    'model'=>$model,'value'=>$model->FECHA,
                    'attribute'=>'FECHA','flat'=>false,  
Example #9
0
/**
 * Returns nil, the empty list.
 */
function nil()
{
    return Cons::nil();
}