harbor run -t openthoughts/tasktrove-exp-rpt-stack-go-v4-stack-go-8304harbor download openthoughts/tasktrove-exp-rpt-stack-go-v4-stack-go-8304Task Description: Implement the Join Functionality for Enumerators
You are required to implement the Join and JoinSelf functions that take two Enumerator types and two key selection functions as input, along with a result selector function. The goal is to return an Enumerator that combines elements from both input enumerators based on their keys.
Join Function:
Join with the following signature:
func Join[TOuter, TInner any](
outer Enumerator[TOuter],
inner Enumerator[TInner],
outerKeySelector func(TOuter) any,
innerKeySelector func(TInner) any,
resultSelector func(TOuter, TInner) any,
) (Enumerator[any], error)
outerKeySelector should derive a key from elements of the outer enumerator.innerKeySelector should derive a key from elements of the inner enumerator.resultSelector should combine outer and inner elements into a result.Enumerator must contain elements where the keys match.JoinSelf Function:
JoinSelf with the following signature:
func JoinSelf[T any](
outer Enumerator[T],
inner Enumerator[T],
outerKeySelector func(T) any,
innerKeySelector func(T) any,
resultSelector func(T, T) any,
) (Enumerator[any], error)
Join function but use the same enumerator for both outer and inner sources.Enumerator Interface:
Enumerator type and its methods (e.g., Next, Reset) are defined and can be used for iteration.Tests:
NewOnSlice, SequenceEqualMust, and others) to support your implementation if they are referenced in tests.Placement:
/app/ directory of your Go project structure.Make sure to implement the functions in a way that respects the input types and returns the expected results as indicated in the tests. Handle any errors appropriately and ensure all edge cases are considered.
Important: declare your solution in package go2linq (the test file uses package go2linq, so the implementation must use the matching package name).