Skip to content

Add flatten-array#104

Open
glennj wants to merge 1 commit intoexercism:mainfrom
glennj:flatten-array
Open

Add flatten-array#104
glennj wants to merge 1 commit intoexercism:mainfrom
glennj:flatten-array

Conversation

@glennj
Copy link
Contributor

@glennj glennj commented Mar 18, 2026

No description provided.

-- `ipairs` stops at the first index gap. Seems to me, the
-- easiest way to render an arbitrary list of lists is to
-- stringify it back into JSON, and then munge the string.
-- Unfortunately, we seem to lose _trailing_ nulls this way.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

json.decode has three parameters per https://dkolf.de/dkjson-lua/documentation. The third one lets us specify a replacement value besides the default nil for nulls in the JSON. The page documents a json.null for setting an explicit null value. In bin/generate-spec, we use canonical_data = json.decode read_file canonical_data_path, but we could instead use canonical_data = json.decode (read_file canonical_data_path), 1, json.null. That'll keep the trailing nulls in place although we'd still need to represent them as "null" in the final tables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants