Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Improvements to Microsoft.Quantum.Arrays #313

@cgranade

Description

@cgranade

Abstract

There is a close connection between the iteration over classical values, and generalizing "circuit"-like patterns into high-level code. In Q#, we use exploit this connection with the Microsoft.Quantum.Arrays namespace to make it easier express high-level patterns. We have noted from user feedback, however, that some common patterns are difficult to express using existing array functions, or that users may not be able to discover needed functionality.

The improvements proposed here empower users to make better use of high-level quantum development in Q# by making it easier to iterate over collections of values, such as Qubit[], and to use them to write out complex algorithmic patterns efficiently.

Proposed deprecations and renamings

  • namespace Microsoft.Quantum.Arrays
    • function Exclude<'T>(remove : Int[], array : 'T[]) : 'T[];
      function Excluding<'T>(remove : Int[], array : 'T[]) : 'T[];
    • function Zip<'T, 'U>(left : 'T[], right : 'U[]) : ('T, 'U)[];
      function Zipped<'T, 'U>(left : 'T[], right : 'U[]) : ('T, 'U)[];

Proposed additions

Future considerations and language feature dependencies

  • Functions like Transposed or ColumnAt may need to be redesigned to work well with 𝑛-d arrays.

Other comments

  • @guenp​​ has suggested that Fold is a reasonable name if there's a way to find it in docs from searching for "reduce." The input name "folder" is dubious, though, regardless; duplicate meaning that can be confused.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Kind-EnhancementNew feature or requestPkg-StandardIssue relates to the Microsoft.Quantum.Standard package.Status-NeedsApiReviewThis PR requires an API review before merging in.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions