Skip to main content
deleted 299 characters in body
Source Link
lyxal
  • 34.3k
  • 2
  • 64
  • 141

Vyxal, 88 3 bytes

λ3|M÷^†;M$R

Try it Online!Try it Online!

This is a function submissionTakes [g, [a, b], f]. If reduction was reversible, then this would be 2 bytes.

Explained

λ3|M÷^†;
λ3|        # start a lambda with an arity of 3, taking [g, f, [a, b]]:M$R
   M       #    map f over [a, b] -> [f(a), f(b)]
    ÷^     #    dump [f(a), f(b)] onto the stack and reverse -> [f(b), f(a), g]
      †   $R #  reduce that applyby g to the stack
       ;   # close lambda

Vyxal, 8 bytes

λ3|M÷^†;

Try it Online!

This is a function submission

Explained

λ3|M÷^†;
λ3|        # start a lambda with an arity of 3, taking [g, f, [a, b]]:
   M       #    map f over [a, b] -> [f(a), f(b)]
    ÷^     #    dump [f(a), f(b)] onto the stack and reverse -> [f(b), f(a), g]
      †    #    apply g to the stack
       ;   # close lambda

Vyxal, 8 3 bytes

M$R

Try it Online!

Takes [g, [a, b], f]. If reduction was reversible, then this would be 2 bytes.

Explained

M$R
M   # map f over [a, b]
 $R # reduce that by g
Source Link
lyxal
  • 34.3k
  • 2
  • 64
  • 141

Vyxal, 8 bytes

λ3|M÷^†;

Try it Online!

This is a function submission

Explained

λ3|M÷^†;
λ3|        # start a lambda with an arity of 3, taking [g, f, [a, b]]:
   M       #    map f over [a, b] -> [f(a), f(b)]
    ÷^     #    dump [f(a), f(b)] onto the stack and reverse -> [f(b), f(a), g]
      †    #    apply g to the stack
       ;   # close lambda