Pythy Finite Ordinals

1

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.

SuperJedi224

Posted 2015-05-06T15:01:49.370

Reputation: 11 342

Question was closed 2015-05-06T17:39:01.023

Are the spaces in the output optional? – Martin Ender – 2015-05-06T15:30:43.303

The spaces in the final output (from the pyth program) are optional. – SuperJedi224 – 2015-05-06T15:34:11.363

The generating program takes the input though, the generated result isn't allowed to take any. – SuperJedi224 – 2015-05-06T15:46:37.657

1It'd be trivial to append something like J<input> at the front. – Sp3000 – 2015-05-06T15:49:51.193

Answers

1

Pyth, 11 10 bytes

"u+G]G"z\]

"Answers must be at least 30 characters."

orlp

Posted 2015-05-06T15:01:49.370

Reputation: 37 067