Fsharpplus: Add `findSliceIndex` function to other collections

Created on 29 Jul 2019  路  5Comments  路  Source: fsprojects/FSharpPlus

Description

Related: https://github.com/fsprojects/FSharpPlus/issues/158#issuecomment-513526420

I propose we add findSliceIndex / tryFindSliceIndex which we recently added to String extension to other collections' extensions.

val findSliceIndex : slice:'Collection<'a> -> source:'Collection<'a> -> int

val tryFindSliceIndex : slice:'Collection<'a> -> source:'Collection<'a> -> int option

It will work just like the existing findIndex : 'a -> 'Collection<'a> -> int but it searches a "slice" (i.e. subsequence, sub-collection) instead of an element String.findIndex.

Most helpful comment

I'm personally fine with this, definitely it makes sense to have them for other collections.

It also makes sense to have the generic version, if you are willing to do this PR I leave it to your criteria/willingness to include the generic functions or not.

Of course, I'm happy to help fighting the compiler ;)

All 5 comments

I'm personally fine with this, definitely it makes sense to have them for other collections.

It also makes sense to have the generic version, if you are willing to do this PR I leave it to your criteria/willingness to include the generic functions or not.

Of course, I'm happy to help fighting the compiler ;)

We don't have generic findIndex yet, so if we are going to add generic findSliceIndex it is better to add it too. If it's OK I'll start a PR and do both.

Yes, go ahead please !

Sounds nice. Would it make sense to have a Slice module?

We can consider it if we ever decide to split our functions in modules.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Shmew picture Shmew  路  9Comments

cmeeren picture cmeeren  路  9Comments

pangwa picture pangwa  路  11Comments

cmeeren picture cmeeren  路  12Comments

Shmew picture Shmew  路  5Comments