Skip to content

Suggestion: repeated transform #92

Description

@niekbouman

Dear Zach,

How about adding a "repeated transform"? (See below, not sure if this is the best form, maybe some perfect forwarding is needed).
Note that it requires the Comparable concept on Expr.

best,
Niek

template <typename Expr, typename TF>
constexpr auto repeated_transform(Expr &&expr, TF&& xform) {
  // apply the transform repeatedly until the result no longer changes

  return hana::while_(
      [&](auto &&x) { return hana::not_equal(x, yap::transform(x, xform)); },
      expr, [&](auto &&ex) { return yap::transform(ex, xform); });
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions