LookupFunction function

Warning

This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.

Please see https://aka.ms/qdk.api for the API documentation for the Modern QDK.

Namespace: Microsoft.Quantum.Arrays

Package: Microsoft.Quantum.Standard

Given an array, returns a function which returns elements of that array.

function LookupFunction<'T> (array : 'T[]) : (Int -> 'T)

Input

array : 'T[]

The array to be represented as a lookup function.

Output : Int -> 'T

A function f such that f(idx) == f[idx].

Type Parameters

'T

The type of the elements of the array being represented as a lookup function.

Remarks

This function is mainly useful for interoperating with functions and operations that take Int -> 'T functions as their arguments. This is common, for instance, in the generator representation library, where functions are used to avoid the need to record an entire array in memory.