Skip to content

Conversation

@JaapWijnen
Copy link
Collaborator

@JaapWijnen JaapWijnen commented Jun 4, 2025

This makes OrderedDictionary.Values conform to the Differentiable protocol.
You can now access the values of an OrderedDictionary in a differentiable way:

@differentiable(reverse)
func example1(dict: OrderedDictionary<String, Double>) -> [Double] {
    dict.values.elements
}

subscripting also works:

@differentiable(reverse)
func example2(dict: OrderedDictionary<String, Double>, index: Int) -> Double {
    dict.values[index]
}

@JaapWijnen JaapWijnen force-pushed the feat/ordereddictionary-values-differentiable branch from 0e7866b to ee8c523 Compare June 4, 2025 12:52
@JaapWijnen JaapWijnen force-pushed the feat/ordereddictionary-values-differentiable branch from ee8c523 to 1f07c13 Compare June 4, 2025 13:01
@clarkdobson
Copy link

Looks good, thanks for adding this functionality!

@JaapWijnen JaapWijnen requested a review from clarkdobson June 5, 2025 16:32
Copy link

@clarkdobson clarkdobson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good as is, should be ready to merge.

@JaapWijnen JaapWijnen merged commit db65fda into main Jun 6, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants