gusty / FsControl

[ARCHIVED] FsControl in now included in FSharpPlus https://fsprojects.github.io/FSharpPlus
Apache License 2.0
105 stars 16 forks source link

Skip and Take throw Exception. #46

Closed gusty closed 9 years ago

gusty commented 9 years ago

An exception is thrown when outside the bounds but that's a problem when using seq aiming for laziness, it will force you to check first the length of the sequence. That's how they're implemented in F# but I prefer the Linq implementation which works as Haskell's drop and take, in those cases it returns an empty list which logically represents 'no results'.

atifaziz commented 9 years ago

The F# equivalent of Take from LINQ is called truncate that does not throw if the sequence has fewer elements than the specified count.

gusty commented 9 years ago

So, may be can we leave them as they are and add another 2 functions: drop and truncate with that (safe) behaviour.

gusty commented 9 years ago

I used the name Limit instead of Truncate because Truncate will conflict with the method of the same name for Numerics.