1
\$\begingroup\$

This question already has an answer here:

Write a program in any language that takes a single natural number n as input and generates a Pyth program that, in turn, produces, using nested lists, the nested set given by S(n), where:

S(0) = ∅
S(n+1) = S(n) ∪ {S(n)}

S(n) giving the set representation of the corresponding ordinal number.

Using the list representation required by this question, this gives (as the final output from the generated Pyth program):

0->[]
1->[[]]
2->[[],[[]]]
3->[[],[[]],[[],[[]]]]
Etc.

Again, the challenge is to write a program in another language for generating the corresponding Pyth program.

This is code golf, so shortest full program wins.

\$\endgroup\$

marked as duplicate by Digital Trauma, Jakube, ProgramFOX, xnor, Calvin's Hobbies May 6 '15 at 17:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • \$\begingroup\$ Are the spaces in the output optional? \$\endgroup\$ – Martin Ender May 6 '15 at 15:30
  • \$\begingroup\$ The spaces in the final output (from the pyth program) are optional. \$\endgroup\$ – SuperJedi224 May 6 '15 at 15:34
  • \$\begingroup\$ The generating program takes the input though, the generated result isn't allowed to take any. \$\endgroup\$ – SuperJedi224 May 6 '15 at 15:46
  • 1
    \$\begingroup\$ It'd be trivial to append something like J<input> at the front. \$\endgroup\$ – Sp3000 May 6 '15 at 15:49
1
\$\begingroup\$

Pyth, 11 10 bytes

"u+G]G"z\]

"Answers must be at least 30 characters."

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.