# Pythy Finite Ordinals [duplicate]

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.

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

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

"u+G]G"z\]