8 ms·
What are the five kinds of lists you need?
by useranme 9y ago
What are the five kinds of lists you need?
- skybrian 9y ago- Phrases (space separated lists): a b (c d) e - Comma-separated lists: a, b, (c, d), e - Square-bracket lists: [a, b, c] - Blocks (curly brackets and separated by newlines or semicolons): { a b; c d } - Dotted lists, where sometimes the dots can be omitted: foo.bar.baz In combination, you can write something like: for x in [1, 2, 3] { foo.bar(x + 1, x * 2) } Which can be interpreted as 7 lists. The top-level list has five items, the last two of which are lists. The last list is a block containing one item, which is a three-item dotted list. The argument list after "bar" is a two-item comma list containing two phrases. I've implemented this, but I'm not satisfied with it; the corner cases are tricky to understand.