示例#1
0
int
main(int argc, char *argv[])
{
	struct val     *vp;

	(void) setlocale(LC_ALL, "");

	if (argc > 1 && !strcmp(argv[1], "--"))
		argv++;

	av = argv + 1;

	nexttoken(0);
	vp = eval0();

	if (token != EOI) {
		error();
		/* NOTREACHED */
	}

	if (vp->type == integer)
		printf("%d\n", vp->u.i);
	else
		printf("%s\n", vp->u.s);

	exit(is_zero_or_null(vp));
}
示例#2
0
/*------------------------------------------------------------------
/
/   eval_user - To add your own eval function, called, for instance
/               my_eval, 
/
/   1. add the function my_eval(int,double*) to the bottom of this file
/
/   2. put the prototype in eval.h 
/
/   3. in eval_user add the lines as in the sample below, 
/
/   4. recompile (make pga)
/
/   5. change the first line in GAin.dat to my_eval
/
/   6. set the number and range of parameters at the bottom of GAin.dat
/
/   7. run pga
/
/------------------------------------------------------------------*/
double eval_user(int iniche,char *f,int n, double* params)
{
  double fitness;

  if(!strcmp(f,"eval0"))
    fitness=eval0(n,params);
  else if(!strcmp(f,"eval1"))
    fitness=eval1(n,params);

/* sample new lines ..._____________
  else if(!strcmp(f,"my_eval"))
    fitness=my_eval(n,params);
 ..._________________________________*/

  else {
    fprintf(stdout,"You have specified a bogus function name: %s\n",f);
    exit(0);
  }
  return fitness;
}
示例#3
0
struct val *
eval6(void)
{
	struct val     *v;

	if (token == OPERAND) {
		nexttoken(0);
		return tokval;

	} else if (token == RP) {
		nexttoken(0);
		v = eval0();

		if (token != LP) {
			error();
			/* NOTREACHED */
		}
		nexttoken(0);
		return v;
	} else {
		error();
	}
	/* NOTREACHED */
}
示例#4
0
Term Yap_eval_atom(Int f)
{
  return eval0(f);
}