That's a fun idea- thank you for sharing!
A few suggestions:
- Instead of using "," to join together long lists of string literals, you could use "split" on a single string. This is more concise, but also a bit more efficient at runtime, since Lil does not (currently) pre-evaluate constant expressions. The following lines are equivalent:
("A","B","CD","EFG","H","I") "|" split "A|B|CD|EFG|H|I"
- If the random[] function is given a single list argument, it will select a single value from that list, whereas specifying a "1" as the second argument will produce a list of length one. The former case appears to be closer to what you want. The following lines are equivalent:
sum random[(1,2,2,3,4) 1] first random[(1,2,2,3,4) 1] random[(1,2,2,3,4)] random[1,2,2,3,4]
- We don't strictly need to "fuse" in both syl[] and word[]; the string-cast of a list of strings is their concatenation, so a single fuse at the top level will collapse nested lists-of-lists-of-strings:
(list "A","B"),(list "C","DEE","EFF") (("A","B"),("C","DEE","EFF")) "" fuse (list "A","B"),(list "C","DEE","EFF") "ABCDEEEFF"
- We can simplify slightly by referencing cons/vow in syl[] as globals, instead of threading them through word[]/syl[] as arguments. Once syl[] doesn't take any arguments, we can observe that the "@" operator is a shorthand for the loop in word[]. The following lines are equivalent:
each x in i syl[] end syl @ i
All together, I think I might factor this program as follows: