diff options
author | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-09 22:24:07 +0000 |
---|---|---|
committer | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-09 22:24:07 +0000 |
commit | 0b8bd8e88f2620992310c7ba41283f5d9120e371 (patch) | |
tree | 428cdf822378a59fc5e5e9b9eb040cd91f64bdbc /eval.c | |
parent | 325cfd6354dcccaa095767e0419760a3f9462fed (diff) |
Add rule for monadic function application
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -9,11 +9,12 @@ Rune *errormsg; typedef Datum (*evalfn)(Datum, Datum); Datum strand(Datum, Datum); +Datum monadfun(Datum, Datum); int bindingstrengths[12][12] = { /* A F H MO DO AF ( ) { } [ ] */ - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* A */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* F */ + 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* A */ + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* F */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* H */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* MO */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* DO */ @@ -29,7 +30,7 @@ int bindingstrengths[12][12] = { evalfn evalfns[12][12] = { /* A F H MO DO AF ( ) { } [ ] */ strand, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* A */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* F */ + monadfun, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* F */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* H */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* MO */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* DO */ @@ -90,4 +91,15 @@ strand(Datum left, Datum right) result.tag = ArrayTag; result.array = fnCatenateFirst(left.array,fnEnclose(right.array)); return result; +} + +Datum +monadfun(Datum left, Datum right) +{ + print("Monadic function application\n"); + Datum result; + result.tag = ArrayTag; + /* TODO handle undefined functions here */ + result.array = monadfunctiondefs[left.code](right.array); + return result; }
\ No newline at end of file |