Building a list of all words of length less than k in a given
- To: mathgroup at smc.vnet.net
- Subject: [mg108338] Building a list of all words of length less than k in a given
- From: NIUNIU LAO <laoniuli at gmail.com>
- Date: Sun, 14 Mar 2010 05:14:23 -0500 (EST)
Hello group, Is there a standard way to : 1)specify an alphabet, here for example the two-letter alphabet {f1,f2} 2)generate all words (aka monic monoid polynomials, aka noncommutative products) of length less than or equal to N with {f1,f2} 3)get results in a list. In my case, I f1,f2 are functions and the product is function composition, which I want to then evaluate at one, or several values x. Consequently I cheated by adding Identity to my alphabet and building all Tuples: my solution is: indices = DeleteDuplicates[Tuples[{f1, f2, Identity}, k]] Table[Apply[Composition, indices[[p]]][x], {p, Length[indices]}] However I guess I am being blundering and suboptimal: if someone knows a more standard, better way, thank you for letting me know! Thank you. Regards, LN