Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I wonder why F# has not generalized the pattern matching over lists to a generalization version for sequences and generated optimized code based on the type use?
it is not uncommon to traverse a collection like you would do with a list to do something depending on the order of the items of the collection appears.
This is not that hard to implement in the compiler since a sequence s like a list either is empty, or has a head and tail which again is a sequence, hence substitute/inline the isEmpty function body with the check for [], and substitute/inline x :: xs with let x = head s; let xs = tail s. for det specific implementation of isEmpty, head and tail for the used collection. it would lead to a better chance that the compiler can recognize doublications of sub-patterns of the matching and merge them leading to more performant code.
Beta Was this translation helpful? Give feedback.
All reactions