This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| func (l *Log) ToString() string { | |
| return fmt.Sprintf("Res: %d, Ops: %s", l.Val, l.Op) | |
| } | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| x := 0 | |
| fmt.Printf("%s\n", bind(bind(bind(unit(x), f1), f2), f3).ToString()) | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| // no more required and not repeated | |
| log += log2 + "; " | |
| log += log3 + "; " | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| func bind(x *Log, f Increment) *Log { | |
| val, op := f(x.Val) | |
| return &Log{Val: val, Op: fmt.Sprintf("%s%s; ", x.Op, op)} | |
| } | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| func unit(x int) *Log { | |
| return &Log{Val: x, Op: ""} | |
| } | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| type Increment func(y int) (int, string) | |
| type Log struct { | |
| Val int | |
| Op string | |
| } | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| func unit(x int) *Log { | |
| return &Log{Val: x, Op: ""} | |
| } | |
| func bind(x *Log, f Increment) *Log { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| x := 0 | |
| log := "Ops: " | |
| res, log1 := f1(x) | |
| log += log1 + "; " | |
| res, log2 := f2(res) | |
| log += log2 + "; " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| func f1(x int) (int, string) { | |
| return x + 1, fmt.Sprintf("%d+1", x) | |
| } | |
| func f2(x int) (int, string) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| func f1(x int) (int, string) { | |
| return x + 1, fmt.Sprintf("%d+1", x) |