Another trampoline bites the dust.
This commit is contained in:
parent
a373667c23
commit
368009e84f
@ -214,36 +214,44 @@ newkeylevel (const int level)
|
||||
return 1;
|
||||
}
|
||||
|
||||
//! count local constants
|
||||
float
|
||||
term_constcount (const System sys, Term t)
|
||||
struct state_tcc
|
||||
{
|
||||
int n, total;
|
||||
float ratio;
|
||||
int leaves;
|
||||
int nonvariables;
|
||||
};
|
||||
|
||||
int countMe (Term t)
|
||||
//! Simple helper for below
|
||||
int
|
||||
countMe (Term t, struct state_tcc *stcc)
|
||||
{
|
||||
if (TermRunid (t) >= 0)
|
||||
{
|
||||
total++;
|
||||
(stcc->leaves)++;
|
||||
if (!isTermVariable (t))
|
||||
{
|
||||
n++;
|
||||
(stcc->nonvariables)++;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
n = 0;
|
||||
total = 0;
|
||||
term_iterate_deVar (t, countMe, NULL, NULL, NULL);
|
||||
if (total == 0)
|
||||
//! count local constants
|
||||
float
|
||||
term_constcount (const System sys, Term t)
|
||||
{
|
||||
float ratio;
|
||||
struct state_tcc Stcc;
|
||||
|
||||
Stcc.nonvariables = 0;
|
||||
Stcc.leaves = 0;
|
||||
term_iterate_state_deVar (t, countMe, NULL, NULL, NULL, &Stcc);
|
||||
if (Stcc.leaves == 0)
|
||||
{
|
||||
ratio = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ratio = ((total - n) / total);
|
||||
ratio = ((Stcc.leaves - Stcc.nonvariables) / Stcc.leaves);
|
||||
}
|
||||
return ratio;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user