MCPcopy
hub / github.com/destel/rill / ExampleMap

Function ExampleMap

example_test.go:656–667  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

654}
655
656func ExampleMap() {
657 // Convert a slice of numbers into a stream
658 numbers := rill.FromSlice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, nil)
659
660 // Transform each number
661 // Concurrency = 3
662 squares := rill.Map(numbers, 3, func(x int) (int, error) {
663 return square(x), nil
664 })
665
666 printStream(squares)
667}
668
669// The same example as for the [Map], but using ordered versions of functions.
670func ExampleOrderedMap() {

Callers

nothing calls this directly

Calls 4

FromSliceFunction · 0.92
MapFunction · 0.92
squareFunction · 0.85
printStreamFunction · 0.85

Tested by

no test coverage detected