Skip to content

sudipto80/fscollections

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

F# Collections

-------------- module array ------------ [array](https://github.com/sudipto80/fscollections/blob/master/array.md)
Function Description
append Creates an array that contains the elements of one array followed by the elements of another array.
average Returns the average of the elements in an array.
averageBy Returns the average of the elements generated by applying a function to each element of an array.
blit Reads a range of elements from one array and writes them into another.
choose Applies a supplied function to each element of an array. Returns an array that contains the results x for each element for which the function returns Some(x) .
collect Applies the supplied function to each element of an array, concatenates the results, and returns the combined array.
concat Creates an array that contains the elements of each of the supplied sequence of arrays.
copy Creates an array that contains the elements of the supplied array.
create Creates an array whose elements are all initially the supplied value.
exists Tests whether any element of an array satisfies the supplied predicate.
exists2 Tests whether any pair of corresponding elements of two arrays satisfy the supplied condition.
fill Fills a range of elements of an array with the supplied value.
filter Returns a collection that contains only the elements of the supplied array for which the supplied condition returns true .
find Returns the first element for which the supplied function returns true . Raises KeyNotFoundException if no such element exists.
findIndex Returns the index of the first element in an array that satisfies the supplied condition. Raises KeyNotFoundException if none of the elements satisfy the condition.
fold Applies a function to each element of an array, threading an accumulator argument through the computation. If the input function is f and the array elements are i0...iN , this function computes f (...(f s i0)...) iN .
fold2 Applies a function to pairs of elements from two supplied arrays, left-to-right, threading an accumulator argument through the computation. The two input arrays must have the same lengths; otherwise, ArgumentException is raised.
foldBack Applies a function to each element of an array, threading an accumulator argument through the computation. If the input function is f and the array elements are i0...iN , this function computes f i0 (...(f iN s)) .
foldBack2 Applies a function to pairs of elements from two supplied arrays, right-to-left, threading an accumulator argument through the computation. The two input arrays must have the same lengths; otherwise, ArgumentException is raised.
forall Tests whether all elements of an array satisfy the supplied condition.
get Gets an element from an array.
isEmpty Tests whether an array has any elements.
iter Applies the supplied function to each element of an array.
iter2 Applies the supplied function to a pair of elements from matching indexes in two arrays. The two arrays must have the same lengths; otherwise, ArgumentException is raised.
iteri Applies the supplied function to each element of an array. The integer passed to the function indicates the index of the element.
iteri2 Applies the supplied function to a pair of elements from matching indexes in two arrays, also passing the index of the elements. The two arrays must have the same lengths; otherwise, an ArgumentException is raised.
length Returns the length of an array. The Length property does the same thing.
map Creates an array whose elements are the results of applying the supplied function to each of the elements of a supplied array.
map2 Creates an array whose elements are the results of applying the supplied function to the corresponding elements of two supplied arrays. The two input arrays must have the same lengths; otherwise, ArgumentException is raised.
mapi Creates an array whose elements are the results of applying the supplied function to each of the elements of a supplied array. An integer index passed to the function indicates the index of the element being transformed.
mapi2 Creates an array whose elements are the results of applying the supplied function to the corresponding elements of the two collections pairwise, also passing the index of the elements. The two input arrays must have the same lengths; otherwise, ArgumentException is raised.
max Returns the largest of all elements of an array. Operators.max is used to compare the elements.
maxBy Returns the largest of all elements of an array, compared via Operators.max on the function result.
min Returns the smallest of all elements of an array. Operators.min is used to compare the elements.
minBy Returns the smallest of all elements of an array. Operators.min is used to compare the elements.
ofList Creates an array from the supplied list.
ofSeq Creates an array from the supplied enumerable object.
partition Splits an array into two arrays, one containing the elements for which the supplied condition returns true , and the other containing those for which it returns false .
permute Permutes the elements of an array according to the specified permutation.
pick Applies the supplied function to successive elements of a supplied array, returning the first result where the function returns Some(x) for some x . If the function never returns Some(x) , KeyNotFoundException is raised.
reduce Applies a function to each element of an array, threading an accumulator argument through the computation. If the input function is f and the array elements are i0...iN , this function computes f (...(f i0 i1)...) iN . If the array has size zero, ArgumentException is raised.
reduceBack Applies a function to each element of an array, threading an accumulator argument through the computation. If the input function is f and the elements are i0...iN , this function computes f i0 (...(f iN-1 iN)) . If the array has size zero, ArgumentException is raised.
rev Reverses the order of the elements in a supplied array.
scan Behaves like fold , but returns the intermediate results together with the final results.
scanBack Behaves like foldBack , but returns the intermediary results together with the final results.
set Sets an element of an array.
sort Sorts the elements of an array and returns a new array. Operators.compare is used to compare the elements.
sortBy Sorts the elements of an array by using the supplied function to transform the elements to the type on which the sort operation is based, and returns a new array. Operators.compare is used to compare the elements.
sortInPlace Sorts the elements of an array by changing the array in place, using the supplied comparison function. Operators.compare is used to compare the elements.
sortInPlaceBy Sorts the elements of an array by changing the array in place, using the supplied projection for the keys. Operators.compare is used to compare the elements.
sortInPlaceWith Sorts the elements of an array by using the supplied comparison function to change the array in place.
sortWith Sorts the elements of an array by using the supplied comparison function, and returns a new array.
sub Creates an array that contains the supplied subrange, which is specified by starting index and length.
sum Returns the sum of the elements in the array.
sumBy Returns the sum of the results generated by applying a function to each element of an array.
toList Converts the supplied array to a list.
tryFind Returns the first element in the supplied array for which the supplied function returns true . Returns None if no such element exists.
tryFindIndex Returns the index of the first element in an array that satisfies the supplied condition.
tryPick Applies the supplied function to successive elements of the supplied array, and returns the first result where the function returns Some(x) for some x . If the function never returns Some(x) , None is returned.
unzip Splits an array of tuple pairs into a tuple of two arrays.
unzip3 Splits an array of tuples of three elements into a tuple of three arrays.
zeroCreate Creates an array whose elements are initially set to the default value Unchecked.defaultof<'T> .
zip Combines two arrays into an array of tuples that have two elements. The two arrays must have equal lengths; otherwise, ArgumentException is raised.
zip3 Combines three arrays into an array of tuples that have three elements. The three arrays must have equal lengths; otherwise, ArgumentException is raised.

list

Function Description
append Returns a new list that contains the elements of the first list followed by elements of the second.
average Returns the average of the elements in the list.
averageBy Returns the average of the elements generated by applying the function to each element of the list.
choose Applies the given function to each element of the list. Returns the list comprised of the results for each element where the function returns Some .
collect For each element of the list, applies the given function. Concatenates all the results and return the combined list.
concat Returns a new list that contains the elements of each the lists in order.
exists Tests if any element of the list satisfies the given predicate.
exists2 Tests if any pair of corresponding elements of the lists satisfies the given predicate.
filter Returns a new collection containing only the elements of the collection for which the given predicate returns true .
find Returns the first element for which the given function returns true .
findIndex Returns the index of the first element in the list that satisfies the given predicate.
fold Applies a function to each element of the collection, threading an accumulator argument through the computation. This function takes the second argument, and applies the function to it and the first element of the list. Then, it passes this result into the function along with the second element, and so on. Finally, it returns the final result. If the input function is f and the elements are i0...iN , then this function computes f (... (f s i0) i1 ...) iN .
fold2 Applies a function to corresponding elements of two collections, threading an accumulator argument through the computation. The collections must have identical sizes. If the input function is f and the elements are i0...iN and j0...jN , then this function computes f (... (f s i0 j0)...) iN jN .
foldBack Applies a function to each element of the collection, threading an accumulator argument through the computation. If the input function is f and the elements are i0...iN then computes f i0 (...(f iN s)) .
foldBack2 Applies a function to corresponding elements of two collections, threading an accumulator argument through the computation. The collections must have identical sizes. If the input function is f and the elements are i0...iN and j0...jN , then this function computes f i0 j0 (...(f iN jN s)) .
forall Tests if all elements of the collection satisfy the given predicate.
forall2 Tests if all corresponding elements of the collection satisfy the given predicate pairwise.
init Creates a list by calling the given generator on each index.
isEmpty Returns true if the list contains no elements, false otherwise.
iter Applies the given function to each element of the collection.
iter2 Applies the given function to two collections simultaneously. The collections must have identical size.
iteri Applies the given function to each element of the collection. The integer passed to the function indicates the index of element.
iteri2 Applies the given function to two collections simultaneously. The collections must have identical size. The integer passed to the function indicates the index of element.
length Returns the length of the list.
map Creates a new collection whose elements are the results of applying the given function to each of the elements of the collection.
map2 Creates a new collection whose elements are the results of applying the given function to the corresponding elements of the two collections pairwise.
map3 Creates a new collection whose elements are the results of applying the given function to the corresponding elements of the three collections simultaneously.
mapi Creates a new collection whose elements are the results of applying the given function to each of the elements of the collection. The integer index passed to the function indicates the index (from 0) of element being transformed.
mapi2 Like List.mapi , but mapping corresponding elements from two lists of equal length.
max Return the greatest of all elements of the list, compared by using Operators.max .
maxBy Returns the greatest of all elements of the list, compared by using Operators.max on the function result.
min Returns the lowest of all elements of the list, compared by using Operators.min .
minBy Returns the lowest of all elements of the list, compared by using Operators.min on the function result
ofArray Creates a list from the given array.
ofSeq Creates a new list from the given enumerable object.
partition Splits the collection into two collections, containing the elements for which the given predicate returns true and false respectively.
permute Returns a list with all elements permuted according to the specified permutation.
pick Applies the given function to successive elements, returning the first result where function returns Some for some value.
reduce Applies a function to each element of the collection, threading an accumulator argument through the computation. This function applies the specified function to the first two elements of the list. It then passes this result into the function along with the third element, and so on. Finally, it returns the final result. If the input function is f and the elements are i0...iN , then this function computes f (... (f i0 i1) i2 ...) iN .
reduceBack Applies a function to each element of the collection, threading an accumulator argument through the computation. If the input function is f and the elements are i0...iN , then this function computes f i0 (...(f iN-1 iN)) .
replicate Creates a list by calling the given generator on each index.
rev Returns a new list with the elements in reverse order.
scan Applies a function to each element of the collection, threading an accumulator argument through the computation. This function takes the second argument, and applies the specified function to it and the first element of the list. Then, it passes this result into the function along with the second element and so on. Finally, it returns the list of intermediate results and the final result.
scanBack Like foldBack , but returns both the intermediate and final results
sort Sorts the given list using Operators.compare .
sortBy Sorts the given list using keys given by the given projection. Keys are compared using Operators.compare .
sortWith Sorts the given list using the given comparison function.
sumBy Returns the sum of the results generated by applying the function to each element of the list.
tail Returns the input list without the first element.
toArray Creates an array from the given list.
toSeq Views the given list as a sequence.
tryFind Returns the first element for which the given function returns true . Return None if no such element exists.
tryFindIndex Returns the index of the first element in the list that satisfies the given predicate. Return None if no such element exists.
tryPick Applies the given function to successive elements, returning the first result where function returns Some for some value. If no such element exists then return None .
unzip Splits a list of pairs into two lists.
unzip3 Splits a list of triples into three lists.
zip Combines the two lists into a list of pairs. The two lists must have equal lengths.
zip3 Combines the three lists into a list of triples. The lists must have equal lengths.

seq

Function Description
append Wraps the two given enumerations as a single concatenated enumeration.
average Returns the average of the elements in the sequence.
averageBy Returns the average of the results generated by applying the function to each element of the sequence.
cache Returns a sequence that corresponds to a cached version of the input sequence.
cast Wraps a loosely-typed System.Collections sequence as a typed sequence.
choose Applies the given function to each element of the list. Return the list comprised of the results for each element where the function returns Some .
collect Applies the given function to each element of the sequence and concatenates all the results.
compareWith Compares two sequences using the given comparison function, element by element.
concat Combines the given enumeration-of-enumerations as a single concatenated enumeration.
countBy Applies a key-generating function to each element of a sequence and return a sequence yielding unique keys and their number of occurrences in the original sequence.
delay Returns a sequence that is built from the given delayed specification of a sequence.
distinct Returns a sequence that contains no duplicate entries according to generic hash and equality comparisons on the entries. If an element occurs multiple times in the sequence then the later occurrences are discarded.
distinctBy Returns a sequence that contains no duplicate entries according to the generic hash and equality comparisons on the keys returned by the given key-generating function. If an element occurs multiple times in the sequence then the later occurrences are discarded.
exactlyOne Returns the only element of the sequence.
exists Tests if any element of the sequence satisfies the given predicate.
exists2 Tests if any pair of corresponding elements of the input sequences satisfies the given predicate.
filter Returns a new collection containing only the elements of the collection for which the given predicate returns true .
find Returns the first element for which the given function returns true .
findIndex Returns the index of the first element for which the given function returns true .
fold Applies a function to each element of the collection, threading an accumulator argument through the computation. If the input function is f and the elements are i0...iN, then this function computes f (... (f s i0)...) iN .
forall Tests if all elements of the sequence satisfy the given predicate.
forall2 Tests the all pairs of elements drawn from the two sequences satisfy the given predicate. If one sequence is shorter than the other then the remaining elements of the longer sequence are ignored.
groupBy Applies a key-generating function to each element of a sequence and yields a sequence of unique keys. Each unique key has also contains a sequence of all elements that match to this key.
head Returns the first element of the sequence.
init Generates a new sequence which, when iterated, returns successive elements by calling the given function, up to the given count. The results of calling the function are not saved, that is, the function is reapplied as necessary to regenerate the elements. The function is passed the index of the item being generated.
initInfinite Generates a new sequence which, when iterated, will return successive elements by calling the given function. The results of calling the function are not saved, that is, the function will be reapplied as necessary to regenerate the elements. The function is passed the index of the item being generated.
isEmpty Tests whether a sequence has any elements.
iter Applies the given function to each element of the collection.
iteri Applies the given function to each element of the collection. The integer passed to the function indicates the index of element.
iter2 Applies the given function to two collections simultaneously. If one sequence is shorter than the other then the remaining elements of the longer sequence are ignored.
last Returns the last element of the sequence.
length Returns the length of the sequence.
map Creates a new collection whose elements are the results of applying the given function to each of the elements of the collection. The given function will be applied as elements are demanded using the MoveNext method on enumerators retrieved from the object.
mapi Creates a new collection whose elements are the results of applying the given function to each of the elements of the collection. The integer index passed to the function indicates the index (from 0) of element being transformed.
map2 Creates a new collection whose elements are the results of applying the given function to the corresponding pairs of elements from the two sequences. If one input sequence is shorter than the other then the remaining elements of the longer sequence are ignored.
max Returns the greatest of all elements of the sequence, compared by using Operators.max .
maxBy Returns the greatest of all elements of the sequence, compared by using Operators.max on the function result.
min Returns the lowest of all elements of the sequence, compared by using Operators.min .
minBy Returns the lowest of all elements of the sequence, compared by using Operators.min on the function result.
nth Computes the nth element in the collection.
ofArray Views the given array as a sequence.
ofList Views the given list as a sequence.
pairwise Returns a sequence of each element in the input sequence and its predecessor, with the exception of the first element which is only returned as the predecessor of the second element.
pick Applies the given function to successive elements, returning the first value where the function returns a Some value.
readonly Creates a new sequence object that delegates to the given sequence object. This ensures the original sequence cannot be rediscovered and mutated by a type cast. For example, if given an array the returned sequence will return the elements of the array, but you cannot cast the returned sequence object to an array.
reduce Applies a function to each element of the sequence, threading an accumulator argument through the computation. Begin by applying the function to the first two elements. Then feed this result into the function along with the third element and so on. Return the final result.
scan Like Seq.fold , but computes on-demand and returns the sequence of intermediary and final results.
singleton Returns a sequence that yields one item only.
skip Returns a sequence that skips a specified number of elements of the underlying sequence and then yields the remaining elements of the sequence.
skipWhile Returns a sequence that, when iterated, skips elements of the underlying sequence while the given predicate returns true , and then yields the remaining elements of the sequence.
sort Yields a sequence ordered by keys.
sum Returns the sum of the elements in the sequence.
sumBy take
take Returns the first elements of the sequence up to a specified count.
takeWhile Returns a sequence that, when iterated, yields elements of the underlying sequence while the given predicate returns true , and then returns no further elements.
toArray Creates an array from the given collection.
toList Creates a list from the given collection.
tryFind Returns the first element for which the given function returns true , or None if no such element exists.
tryFindIndex Returns the index of the first element in the sequence that satisfies the given predicate, or None if no such element exists.
tryPick Applies the given function to successive elements, returning the first value where the function returns a Some value.
truncate Returns a sequence that when enumerated returns no more than a specified number of elements.
unfold Returns a sequence that contains the elements generated by the given computation.
where Returns a new collection containing only the elements of the collection for which the given predicate returns true . A synonym for Seq.filter .
windowed Returns a sequence that yields sliding windows of containing elements drawn from the input sequence. Each window is returned as a fresh array.
zip Combines the two sequences into a list of pairs. The two sequences need not have equal lengths: when one sequence is exhausted any remaining elements in the other sequence are ignored.
zip3 Combines the three sequences into a list of triples. The sequences need not have equal lengths: when one sequence is exhausted any remaining elements in the other sequences are ignored.

map

Function Description
add Returns a new map with the binding added to the given map.
containsKey Tests if an element is in the domain of the map.
exists Returns true if the given predicate returns true for one of the bindings in the map.
filter Creates a new map containing only the bindings for which the given predicate returns true .
find Looks up an element in the map.
findKey Evaluates the function on each mapping in the collection. Returns the key for the first mapping where the function returns true .
fold Folds over the bindings in the map
foldBack Folds over the bindings in the map.
forall Returns true if the given predicate returns true for all of the bindings in the map.
isEmpty Tests whether the map has any bindings.
iter Applies the given function to each binding in the dictionary
map Creates a new collection whose elements are the results of applying the given function to each of the elements of the collection. The key passed to the function indicates the key of element being transformed.
ofArray Returns a new map made from the given bindings.
ofList Returns a new map made from the given bindings.
ofSeq Returns a new map made from the given bindings.
partition Creates two new maps, one containing the bindings for which the given predicate returns true , and the other the remaining bindings.
pick Searches the map looking for the first element where the given function returns a Some value
remove Removes an element from the domain of the map. No exception is raised if the element is not present.
toArray Returns an array of all key/value pairs in the mapping. The array will be ordered by the keys of the map.
toList Returns a list of all key/value pairs in the mapping. The list will be ordered by the keys of the map.
toSeq Views the collection as an enumerable sequence of pairs. The sequence will be ordered by the keys of the map.
tryFind Looks up an element in the map, returning a Some value if the element is in the domain of the map, or None if not.
tryFindKey Returns the key of the first mapping in the collection that satisfies the given predicate, or returns None if no such element exists.
tryPick Searches the map looking for the first element where the given function returns a Some value.

set

Function Description
add Returns a new set with an element added to the set. No exception is raised if the set already contains the given element.
contains Evaluates to true if the given element is in the given set.
count Returns the number of elements in the set.
difference Returns a new set with the elements of the second set removed from the first.
exists Tests if any element of the collection satisfies the given predicate. If the input function is predicate and the elements are i0...iN , then this function computes predicate i0 or ... or predicate iN .
filter Returns a new collection containing only the elements of the collection for which the given predicate returns true .
fold Applies the given accumulating function to all the elements of the set
foldBack Applies the given accumulating function to all the elements of the set.
forall Tests if all elements of the collection satisfy the given predicate. If the input function is p and the elements are i0...iN, then this function computes p i0 && ... && p iN .
intersect Computes the intersection of the two sets.
intersectMany Computes the intersection of a sequence of sets. The sequence must be non-empty.
isEmpty Returns true if the set is empty.
isProperSubset Evaluates to true if all elements of the first set are in the second, and at least one element of the second is not in the first.
isProperSuperset Evaluates to true if all elements of the second set are in the first, and at least one element of the first is not in the second.
isSubset Evaluates to true if all elements of the first set are in the second
isSuperset Evaluates to true if all elements of the second set are in the first.
iter Applies the given function to each element of the set, in order according to the comparison function.
map Returns a new collection containing the results of applying the given function to each element of the input set.
maxElement Returns the highest element in the set according to the ordering being used for the set.
minElement Returns the lowest element in the set according to the ordering being used for the set.
ofArray Creates a set that contains the same elements as the given array.
ofList Creates a set that contains the same elements as the given list.
ofSeq Creates a new collection from the given enumerable object.
partition Splits the set into two sets containing the elements for which the given predicate returns true and false respectively.
remove Returns a new set with the given element removed. No exception is raised if the set doesn't contain the given element.
singleton The set containing the given element.
toArray Creates an array that contains the elements of the set in order.
toSeq Returns an ordered view of the collection as an enumerable object.
union Computes the union of the two sets.
unionMany Computes the union of a sequence of sets.

About

All method details of all F# Modules

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published