Documents composed of randomly selected document portions

I am experimenting with composing a document out of randomly selected pieces. I placed a few letters in a tuple and can select one randomly (with the help of a Scheme form), but I cannot put longer document pieces into a tuple. I did not yet investigate what is allowed within a tuple: perhaps only inline content?
If with a a tuple I cannot use a multi-paragraph document piece, what are other possible ideas?

I think \tuple are not meant for this. You would need to go “fully” scheme and use scheme lists. Alternatively you need to define you own tag “my-tuple” with variadic arguments (like a “screens” tag), so that TeXmacs will not try to “simplify it”.

Thanks. Right now it seems likely that I’ll have to use Scheme. Longer description below, but given that it is complicated, I am maybe too much in the dark on how it works (id est, I am trying random things) and that the same can be done through Scheme, it is fine if you do not go into its details.

I have tried

<assign|doc-tuple|<xmacro|args|<arg|args|<extern|(stree-\<gtr\>tree (random 3))>>>>

and if I use this xmacro with three arguments I obtain arg args as output :slight_smile:

Besides this, I had to insert the arg tag “artificially” (copy-paste from somewhere else), as the editor does not transform slash arg into it; instead of copy-pasting one can also insert first the quote-arg tag, then transform it into the arg tag using the menu.
Moreover, looking at the definition of screen, I think I have to use a surround tag in the body.
I tried wrapping the body of the above xmacro in a surround tag, but, despite this, TeXmacs does not let me insert paragraphs as arguments of the macro. It is instead possible to use the surround tag to insert paragraphs as arguments of a tuple, but the line spacing of the typeset macro output was different from the line spacing of the rest of the document in my test.

I think it is enough :slight_smile:

Another suggestion: what about using a table with one column to store the various pieces. In this way you can still edit them and add some more if needed, and an easy scheme script could just find what it needs by looking up cells in the table.