include/tenzr/txpr/control_flow.h
Namespaces
Classes
Source code
// Copyright 2026 The Tenzr Project Authors
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef TENZR_TXPR_CONTROL_FLOW_H_
#define TENZR_TXPR_CONTROL_FLOW_H_
#include <concepts>
#include <functional>
#include <utility>
#include <vector>
#include "tenzr/array.h"
#include "tenzr/common/export.h"
namespace tenzr::txpr {
struct ScanResult {
Array carry;
Array ys;
};
[[nodiscard]] TENZR_API Array Cond(const Array& pred, const std::function<Array()>& true_fn, const std::function<Array()>& false_fn);
[[nodiscard]] TENZR_API Array Cond(const Array& pred, const std::function<Array(const Array&)>& true_fn, const std::function<Array(const Array&)>& false_fn,
const Array& operand);
[[nodiscard]] TENZR_API ScanResult Scan(const std::function<ScanResult(const Array& carry, const Array& x)>& body_fn, const Array& init_carry,
const Array& xs, int64_t length = -1);
[[nodiscard]] TENZR_API Array WhileLoop(const std::function<Array(const Array&)>& cond_fn, const std::function<Array(const Array&)>& body_fn,
const Array& init_val);
} // namespace tenzr::txpr
namespace tenzr {
namespace lax {
using txpr::Cond;
using txpr::Scan;
using txpr::WhileLoop;
} // namespace lax
using txpr::Cond;
using txpr::Scan;
using txpr::WhileLoop;
} // namespace tenzr
#endif // TENZR_TXPR_CONTROL_FLOW_H_