MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / SliceTransform

Function SliceTransform

pkg/util/util.go:48–54  ·  view source on GitHub ↗

SliceTransform takes an input collection, applies the transform function to each row, and returns the output. Known as 'map' in most other languages or 'Select' in C# Linq.

(slice []T, transform func(item T) TResult)

Source from the content-addressed store, hash-verified

46// SliceTransform takes an input collection, applies the transform function to each row, and returns the output.
47// Known as 'map' in most other languages or 'Select' in C# Linq.
48func SliceTransform[T any, TResult any](slice []T, transform func(item T) TResult) []TResult {
49 var results []TResult = nil
50 for _, item := range slice {
51 results = append(results, transform(item))
52 }
53 return results
54}
55
56// SliceFilter takes an input collection and returns elements where `predicate` returns true
57// Known as 'filter' in most other languages or 'Select' in C# Linq.

Callers 15

AskTenantsAndTagsFunction · 0.92
AskExcludedStepsFunction · 0.92
AskQuestionsFunction · 0.92
formatScopeListFunction · 0.92
formatProcessListFunction · 0.92
PromptScopeFunction · 0.92
PromptMissingFunction · 0.92
PromptMissingFunction · 0.92
createRunFunction · 0.92

Calls

no outgoing calls

Tested by 1