Documentation ¶
Overview ¶
Code generated by github.com/goghcrow/go-co DO NOT EDIT.
Index ¶
- func Fibonacci() ʂɘʠ.Iterator[int]
- func Grep(s string, lines []string) (_ ʂɘʠ.Iterator[string])
- func PowersOfTwo(exponent int) (_ ʂɘʠ.Iterator[int])
- func Range(start, end, step int) (_ ʂɘʠ.Iterator[int])
- func ReadFile(name string) (_ ʂɘʠ.Iterator[Line])
- func Run()
- func SampleGetEvenNumbers(start, end int) (_ ʂɘʠ.Iterator[int])
- func SampleGetNumList() (_ ʂɘʠ.Iterator[int])
- func SampleLoop() (_ ʂɘʠ.Iterator[any])
- func SampleLoopMap() (_ ʂɘʠ.Iterator[Pair[string, int]])
- func SampleYieldFrom() (_ ʂɘʠ.Iterator[int])
- type Line
- type Pair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Grep ¶
func Grep(s string, lines []string) (_ Iter[string]) { for _, line := range lines { if strings.Contains(line, s) { Yield(line) } } return }
func PowersOfTwo ¶
func PowersOfTwo(exponent int) (_ Iter[int]) { for r, i := 1, 0; i < exponent; i++ { Yield(r) r *= 2 } return }
func Range ¶
func Range(start, end, step int) (_ Iter[int]) { for i := start; i < end; i += step { Yield(i) } return }
func ReadFile ¶
func ReadFile(name string) (_ Iter[Line]) { file, err := os.Open(name) if err != nil { Yield(Line{Err: err}) return } r := bufio.NewReader(file) for { line, prefix, err := r.ReadLine() if err == io.EOF { break } else if err != nil { Yield(Line{Err: err}) } else { Yield(Line{Bytes: line, Prefix: prefix, Err: err}) } } return }
func SampleGetEvenNumbers ¶
func SampleGetEvenNumbers(start, end int) (_ Iter[int]) { for i := start; i < end; i++ { if i%2 == 0 { Yield(i) } } return }
func SampleGetNumList ¶
func SampleGetNumList() (_ Iter[int]) { Yield(1) Yield(2) Yield(3) return }
func SampleLoop ¶
func SampleLoop() (_ Iter[any]) { for i := 0; i < 5; i++ { Yield(i) } xs := []string{"a", "b", "c"} for i, n := range xs { Yield(Pair[int, string]{i, n}) } for i, c := range "Hello World!" { Yield(Pair[int, rune]{i, c}) } return }
func SampleLoopMap ¶
func SampleLoopMap() (_ Iter[Pair[string, int]]) { m := map[string]int{"a": 1, "b": 2, "c": 3} for k, v := range m { Yield(Pair[string, int]{k, v}) } return }
func SampleYieldFrom ¶
func SampleYieldFrom() (_ Iter[int]) { Yield(0) YieldFrom(SampleGetNumList()) Yield(4) return }
Types ¶
Directories ¶
Path | Synopsis |
---|---|
Code generated by github.com/goghcrow/go-co DO NOT EDIT.
|
Code generated by github.com/goghcrow/go-co DO NOT EDIT. |
Code generated by github.com/goghcrow/go-co DO NOT EDIT.
|
Code generated by github.com/goghcrow/go-co DO NOT EDIT. |
Code generated by github.com/goghcrow/go-co DO NOT EDIT.
|
Code generated by github.com/goghcrow/go-co DO NOT EDIT. |
Code generated by github.com/goghcrow/go-co DO NOT EDIT.
|
Code generated by github.com/goghcrow/go-co DO NOT EDIT. |
Code generated by github.com/goghcrow/go-co DO NOT EDIT.
|
Code generated by github.com/goghcrow/go-co DO NOT EDIT. |
Code generated by github.com/goghcrow/go-co DO NOT EDIT.
|
Code generated by github.com/goghcrow/go-co DO NOT EDIT. |
Click to show internal directories.
Click to hide internal directories.