struct lambda *t = $1;
printf(" ");
for(unsigned int i = 0; i<999; i++)
- if(!lambda_reduce(&t, &t, true))
+ if(!lambda_reduce(&t, &t, false))
break;
lambda_print(t, NULL);
putchar('\n');
#include "print.h"
#include "mem.h"
-#define binder(t) (*t)->data.identifier.binding
#define lhs(t) (*t)->data.application.expr1
#define rhs(t) (*t)->data.application.expr2
#define bdy(t) (*t)->data.abstraction.expr
void lambda_beta(struct lambda *binding, struct lambda **body, struct lambda *target, struct lambda *total)
{
-// lambda_print(*body, NULL);
-// printf(" [%s=", binding->data.abstraction.ident);
-// lambda_print(target, NULL);
-// printf("]\n");
switch((*body)->which){
case lambda_ident:
- if(binder(body) == binding){
+ if((*body)->data.identifier.binding == binding){
lambda_free(*body);
*body = target;
target->refcount++;
if(lhs(t)->data.abstraction.strict)
lambda_reduce(&rhs(t), total, true);
- if(lhs(t) == rhs(t))
+ if(lhs(t) == rhs(t)){
+ lhs(t)->refcount--;
rhs(t) = copy(rhs(t));
+ }
//In this abstraction we substitute the result with the rhs
lambda_print(*total, *t);