⚡ Sangsakala Proxy 🏠 Home
Skip to content

Add fixed point combinator #372

Open

Description

@jbgi

useful for defining recursive functions via lambda syntax.

Activity

  1. jbgi commented on Oct 26, 2018

    @jbgi
    MemberAuthor

    Here is what I have in mind:

      static <A> A fix(F<A, A> f, F<F0<A>, A> delay) {
        return new Object() {
          final A a = delay.f(() -> f.f(this.a));
        }.a;
      }
      static <A, B> F<A, B> rec(F<F<A, B>, F<A, B>> f, F<F0<B>, B> delay) {
        return new F<A, B>() {
          final F<A, B> rec = f.f(this);
          @Override
          public B f(A a) {
            return delay.f(() -> rec.f(a));
          }
        };
      }

    Does that make sense?

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