Skip to main content
Commonmark migration
Source Link

Attache, 15 + 126 = 141 bytes

A:

AllInput[]|Echo 

Try it online!

B:

@{If[_,s.="AllInput[]|Echo@{If[_,s.=%s;;Printf[s,Repr!s],AllInput[]|Echo]es}|Call";;Printf[s,Repr!s],AllInput[]|Echo]es}|Call 

Try it online!

A + B:

AllInput[]|Echo@{If[_,s.="AllInput[]|Echo@{If[_,s.=%s;;Printf[s,Repr!s],AllInput[]|Echo]es}|Call";;Printf[s,Repr!s],AllInput[]|Echo]es}|Call 

Try it online!

Explanation

Each of the cat program encodes AllInput[]|Echo, which is a simple cat program. B is the main quine phase; alone, it is a vectorized function (through unary @) called with no inputs (being called as |Call). Thus, the first conditional If[_,A,B] executes B, which is simply AllInput[]|Echo.

When A + B is executed, unary @ becomes binary @ due to Echo merging with the lambda:

AllInput[]|Echo@{If[_, ... 

Now, this means that the lambda is executed before Echo is. Back to the conditional, this function now has all of STDIN as an argument. So, If[_,A,B] executes A, which is the standard quine framework.

Attache, 15 + 126 = 141 bytes

A:

AllInput[]|Echo 

Try it online!

B:

@{If[_,s.="AllInput[]|Echo@{If[_,s.=%s;;Printf[s,Repr!s],AllInput[]|Echo]es}|Call";;Printf[s,Repr!s],AllInput[]|Echo]es}|Call 

Try it online!

A + B:

AllInput[]|Echo@{If[_,s.="AllInput[]|Echo@{If[_,s.=%s;;Printf[s,Repr!s],AllInput[]|Echo]es}|Call";;Printf[s,Repr!s],AllInput[]|Echo]es}|Call 

Try it online!

Explanation

Each of the cat program encodes AllInput[]|Echo, which is a simple cat program. B is the main quine phase; alone, it is a vectorized function (through unary @) called with no inputs (being called as |Call). Thus, the first conditional If[_,A,B] executes B, which is simply AllInput[]|Echo.

When A + B is executed, unary @ becomes binary @ due to Echo merging with the lambda:

AllInput[]|Echo@{If[_, ... 

Now, this means that the lambda is executed before Echo is. Back to the conditional, this function now has all of STDIN as an argument. So, If[_,A,B] executes A, which is the standard quine framework.

Attache, 15 + 126 = 141 bytes

A:

AllInput[]|Echo 

Try it online!

B:

@{If[_,s.="AllInput[]|Echo@{If[_,s.=%s;;Printf[s,Repr!s],AllInput[]|Echo]es}|Call";;Printf[s,Repr!s],AllInput[]|Echo]es}|Call 

Try it online!

A + B:

AllInput[]|Echo@{If[_,s.="AllInput[]|Echo@{If[_,s.=%s;;Printf[s,Repr!s],AllInput[]|Echo]es}|Call";;Printf[s,Repr!s],AllInput[]|Echo]es}|Call 

Try it online!

Explanation

Each of the cat program encodes AllInput[]|Echo, which is a simple cat program. B is the main quine phase; alone, it is a vectorized function (through unary @) called with no inputs (being called as |Call). Thus, the first conditional If[_,A,B] executes B, which is simply AllInput[]|Echo.

When A + B is executed, unary @ becomes binary @ due to Echo merging with the lambda:

AllInput[]|Echo@{If[_, ... 

Now, this means that the lambda is executed before Echo is. Back to the conditional, this function now has all of STDIN as an argument. So, If[_,A,B] executes A, which is the standard quine framework.

Source Link
Conor O'Brien
  • 40.4k
  • 3
  • 96
  • 182

Attache, 15 + 126 = 141 bytes

A:

AllInput[]|Echo 

Try it online!

B:

@{If[_,s.="AllInput[]|Echo@{If[_,s.=%s;;Printf[s,Repr!s],AllInput[]|Echo]es}|Call";;Printf[s,Repr!s],AllInput[]|Echo]es}|Call 

Try it online!

A + B:

AllInput[]|Echo@{If[_,s.="AllInput[]|Echo@{If[_,s.=%s;;Printf[s,Repr!s],AllInput[]|Echo]es}|Call";;Printf[s,Repr!s],AllInput[]|Echo]es}|Call 

Try it online!

Explanation

Each of the cat program encodes AllInput[]|Echo, which is a simple cat program. B is the main quine phase; alone, it is a vectorized function (through unary @) called with no inputs (being called as |Call). Thus, the first conditional If[_,A,B] executes B, which is simply AllInput[]|Echo.

When A + B is executed, unary @ becomes binary @ due to Echo merging with the lambda:

AllInput[]|Echo@{If[_, ... 

Now, this means that the lambda is executed before Echo is. Back to the conditional, this function now has all of STDIN as an argument. So, If[_,A,B] executes A, which is the standard quine framework.