Fixed issue with lambdas

This commit is contained in:
Devine Lu Linvega 2024-04-11 12:41:05 -07:00
parent 4bedea3880
commit 3b415e52da
2 changed files with 9 additions and 0 deletions

8
examples/map.modal Normal file
View File

@ -0,0 +1,8 @@
<> (foo ?x) (?x)
<> (map ?x (list ?l)) (map/l map/x ?x ?l)
<> (map/x ?x (?h ?t)) (?x ?h (map/x ?x ?t))
<> (map/x ?x (?h)) (map/r (?x ?h))
<> (?h (map/r ?t)) (?map/r (?h ?t))
<> (map/l map/r ?l) (list ?l)
map foo (list (1 (2 (3 (4 (5))))))

View File

@ -177,6 +177,7 @@ rewrite(void)
if(s[0] == '?' && s[1] == '(') { if(s[0] == '?' && s[1] == '(') {
r = &lambda; r = &lambda;
s = create_rule(&lambda, -1, s) + 1; s = create_rule(&lambda, -1, s) + 1;
while((c = *s) && c <= ' ') s++;
if((res = match_rule(&lambda, s)) != NULL) if((res = match_rule(&lambda, s)) != NULL)
return write_rule(&lambda, last, res); return write_rule(&lambda, last, res);
} }