1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-08-10 22:31:32 +02:00

fix: optimize PipeXXX calls

Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
Dr. Carsten Leue
2024-01-31 21:50:33 +01:00
parent 7d3759619c
commit b077fed094
3 changed files with 1048 additions and 1257 deletions

View File

@@ -265,10 +265,15 @@ func generatePipe(f *os.File, i int) {
fmt.Fprintf(f, ", f%d F%d", j, j)
}
fmt.Fprintf(f, ") T%d {\n", i)
for j := 1; j <= i; j++ {
fmt.Fprintf(f, " t%d := f%d(t%d)\n", j, j, j-1)
fmt.Fprintf(f, " return ")
for j := i; j >= 1; j-- {
fmt.Fprintf(f, "f%d(", j)
}
fmt.Fprintf(f, " return t%d\n", i)
fmt.Fprintf(f, "t0")
for j := 1; j <= i; j++ {
fmt.Fprintf(f, ")")
}
fmt.Fprintf(f, "\n")
fmt.Fprintln(f, "}")
}