Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify definition of internal function columns #442

Merged
merged 2 commits into from
Apr 7, 2023
Merged

Simplify definition of internal function columns #442

merged 2 commits into from
Apr 7, 2023

Conversation

ivanperez-keera
Copy link
Contributor

The internal function columns is building a list with the first element of each sublist, applying an auxiliary function f to it, and then proceeding recursively with the tails of all lists.

This is the same as transposing the list of lists so that all the first elements of the sublists are grouped together, all the second elements are grouped together, and so on, and then applying f to each resulting sublist.

This commit simplifies the definition of columns by using Data.List.transpose.

The internal function columns is building a list with the first element
of each sublist, applying an auxiliary function f to it, and then
proceeding recursively with the tails of all lists.

This is the same as transposing the list of lists so that all the first
elements of the sublists are grouped together, all the second elements
are grouped together, and so on, and then applying f to each resulting
sublist.

This commit simplifies the definition of columns by using
Data.List.transpose.
@ivanperez-keera ivanperez-keera changed the title Simplify definition of internal function columns. Simplify definition of internal function columns Apr 7, 2023
@ivanperez-keera ivanperez-keera changed the title Simplify definition of internal function columns Simplify definition of internal function columns Apr 7, 2023
Copy link
Member

@andreasabel andreasabel left a comment

Choose a reason for hiding this comment

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

Thanks, indeed! (Quickcheck confirms this).

I think columns can now be inlined.

widths = map maximum $ transpose $ map (map length) m

Do you want to do this step?

The internal function columns, used only as part of BNFC.Utils.table, is
relatively small after a prior simplification.

This commit inlines the definition of columns in the only place where it
is used.
@ivanperez-keera
Copy link
Contributor Author

@andreasabel done!

Copy link
Member

@andreasabel andreasabel left a comment

Choose a reason for hiding this comment

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

Thanks!

@andreasabel andreasabel added this to the 2.9.5 milestone Apr 7, 2023
@andreasabel andreasabel merged commit 53e66b4 into BNFC:master Apr 7, 2023
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