Added new Apply{,A,C,CA} operation. (#118)

This commit is contained in:
Chris Granade 2019-05-29 14:55:21 -07:00 коммит произвёл GitHub
Родитель e7f41f2999
Коммит 208b5b6bc5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 87 добавлений и 0 удалений

Просмотреть файл

@ -120,6 +120,93 @@ namespace Microsoft.Quantum.Convert {
return BoolArrayAsInt(ResultArrayAsBoolArray(results));
}
/// # Summary
/// Applies an operation to a given input.
///
/// # Description
/// Given an operation and an input to that operation, applies the operation
/// and returns its output.
///
/// # Input
/// ## op
/// An operation to be applied
/// ## input
/// The input to be passed to the operation.
///
/// # Output
/// The result of calling `op`.
///
/// # See Also
/// - ApplyA
/// - ApplyC
/// - ApplyCA
operation Apply<'Input, 'Output>(op : ('Input => 'Output), input : 'Input) : 'Output {
return op(input);
}
/// # Summary
/// Applies an operation to a given input.
///
/// # Description
/// Given an operation and an input to that operation, applies the operation.
///
/// # Input
/// ## op
/// An operation to be applied
/// ## input
/// The input to be passed to the operation.
///
/// # See Also
/// - Apply
/// - ApplyC
/// - ApplyCA
operation ApplyA<'Input>(op : ('Input => Unit is Adj), input : 'Input) : Unit
is Adj {
op(input);
}
/// # Summary
/// Applies an operation to a given input.
///
/// # Description
/// Given an operation and an input to that operation, applies the operation.
///
/// # Input
/// ## op
/// An operation to be applied
/// ## input
/// The input to be passed to the operation.
///
/// # See Also
/// - Apply
/// - ApplyA
/// - ApplyCA
operation ApplyC<'Input>(op : ('Input => Unit is Ctl), input : 'Input) : Unit
is Ctl {
op(input);
}
/// # Summary
/// Applies an operation to a given input.
///
/// # Description
/// Given an operation and an input to that operation, applies the operation.
///
/// # Input
/// ## op
/// An operation to be applied
/// ## input
/// The input to be passed to the operation.
///
/// # See Also
/// - Apply
/// - ApplyA
/// - ApplyC
operation ApplyCA<'Input>(op : ('Input => Unit is Adj + Ctl), input : 'Input) : Unit
is Adj + Ctl {
op(input);
}
/// # Summary
/// Calls a function with a given input.
///