diff options
author | Eduardo Julian | 2017-06-06 20:23:15 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-06-06 20:23:15 -0400 |
commit | 4480e41e949ba3ba0c9bceeed43e3f144f82103b (patch) | |
tree | e31476d83b24a55746738c0b0b5100931ce289c3 /new-luxc/source/luxc/synthesizer/structure.lux | |
parent | aa3dcb411db1bfbf41ca59c334c6c792b9e40d0c (diff) |
- Now optimizing functions.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/synthesizer/structure.lux | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/new-luxc/source/luxc/synthesizer/structure.lux b/new-luxc/source/luxc/synthesizer/structure.lux new file mode 100644 index 000000000..403817c53 --- /dev/null +++ b/new-luxc/source/luxc/synthesizer/structure.lux @@ -0,0 +1,28 @@ +(;module: + lux + (luxc (lang ["la" analysis]))) + +(def: #export (unfold-tuple tuple) + (-> la;Analysis (List la;Analysis)) + (case tuple + (#la;Product left right) + (#;Cons left (unfold-tuple right)) + + _ + (list tuple))) + +(def: #export (unfold-variant variant) + (-> (Either la;Analysis la;Analysis) [Nat Bool la;Analysis]) + (loop [so-far +0 + variantA variant] + (case variantA + (#;Left valueA) + (case valueA + (#la;Sum choice) + (recur (n.inc so-far) choice) + + _ + [so-far false valueA]) + + (#;Right valueA) + [(n.inc so-far) true valueA]))) |