Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+1)

Following up with an example of something I've used lilt for! It isn't much, but I'm hoping it becomes a part of a larger cli game I've got brewing. 

I've re-implemented a bit of code that I've written a few times in a few languages that creates nonsense, but mostly pronounceable words. 

My goal here was to implement it in what felt like the most idiomatic flavor of lil I could. I've provided a links to previous iterations of this code as a way to compare and contrast the capabilities of lilt. While this is a pretty minimal example, I found it insightful to write. 

(1 edit) (+1)

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:


(+1)

Thanks so much for this super detailed walkthrough! I just learned a heap! My first instinct was to use the @ operator, but I see now that I was going slight awry when I was trying to make the right value a single integer 🤦

This is absolutely gorgeous. To "get" lil more, I've been reading through a few things on apl and k. lil is proving to be a lovely "on-ramp" to array programming for my sufficiently poisoned brain that is stuck in a deeply functional rut. .