diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2023-04-19 13:48:15 +0100 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2023-04-19 13:48:15 +0100 |
commit | d3d17484012dc603ae326bec419cff990898e6a0 (patch) | |
tree | 44aa5b05b6aa3f9b988e6cd59ddacec04660ff32 /subex/subexast.go | |
parent | 58d50737702adc48604f0a709080dcc587d7145f (diff) | |
download | stred-go-d3d17484012dc603ae326bec419cff990898e6a0.tar |
Adds the reciprocal operator
Diffstat (limited to 'subex/subexast.go')
-rw-r--r-- | subex/subexast.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/subex/subexast.go b/subex/subexast.go index 3c807ee..78c9aff 100644 --- a/subex/subexast.go +++ b/subex/subexast.go @@ -223,3 +223,18 @@ func (ast SubexASTNegate) compileWith(next SubexState) SubexState { }), } } + +// Runs the content Subex and collects the output +// If it is a list of atoms castable to numbers, it takes the reciprocal of them all and outputs them +// Else it rejects +type SubexASTReciprocal struct { + content SubexAST +} +func (ast SubexASTReciprocal) compileWith(next SubexState) SubexState { + return &SubexCaptureBeginState { + next: ast.content.compileWith(&SubexArithmeticEndState { + next: next, + calculate: reciprocalValues, + }), + } +} |