Generate outside of loop

This commit is contained in:
Smaug123
2024-02-16 14:07:15 +00:00
parent 65d2263a6c
commit b7f7db8c11
3 changed files with 141 additions and 3 deletions

View File

@@ -75,7 +75,7 @@ module TailRecCata =
| Child
| Parent
let private loop (cata : Cata<_, _>) (instructions : ResizeArray<_>) =
let private loop (cata : Cata<_, _>) (instructions : ResizeArray<Instruction>) =
let resultsStack = ResizeArray ()
let builderResultsStack = ResizeArray ()

View File

@@ -38,7 +38,7 @@ type Cata<'Expr, 'ExprBuilder> =
ExprBuilder : ExprBuilderCata<'Expr, 'ExprBuilder>
}
/// Catamorphism
/// Methods to perform a catamorphism over the type Expr
[<RequireQualifiedAccess>]
module ExprCata =
[<RequireQualifiedAccess>]
@@ -51,6 +51,11 @@ module ExprCata =
| ExprBuilderChild
| ExprBuilderParent
let private loop (cata : Cata<_, _>) (instructions : ResizeArray<Instruction>) =
let ExprBuilderStack = ResizeArray ()
let ExprStack = ResizeArray ()
ExprStack, ExprBuilderStack
/// Execute the catamorphism.
let runExpr (cata : Cata<'ExprRet, 'ExprBuilderRet>) (x : Expr) : 'ExprRet =
let instructions = ResizeArray ()