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

Add generic DisplayString function #5163

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

danielrademacher
Copy link
Contributor

@danielrademacher danielrademacher commented Oct 21, 2022

Start of PR which Resolves #5144

Text for release notes

none

@fingolfin
Copy link
Member

You write that this "fixes" (should perhaps be: "resolves" ?) issue #5144, but as far as I can tell, it only addresses part of it?

lib/matobj.gi Outdated Show resolved Hide resolved
od;
Append(outputstring,"]");
Append(outputstring, ">\n");
return outputstring;
Copy link
Member

Choose a reason for hiding this comment

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

Add a test case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will be done. Which file would you prefer?

@fingolfin fingolfin added the gapdays2022-summer Issues and PRs that arose at https://www.gapdays.de/gapdays2022-summer label Oct 21, 2022
lib/matobj.gi Outdated Show resolved Hide resolved
lib/matobj.gi Show resolved Hide resolved
lib/matobj.gi Outdated Show resolved Hide resolved
lib/matobj.gi Outdated Show resolved Hide resolved
lib/matobj.gi Outdated Show resolved Hide resolved
lib/matobj.gi Outdated Show resolved Hide resolved
@danielrademacher
Copy link
Contributor Author

danielrademacher commented Oct 22, 2022

How should we deal with numbers of different length, i.e.

gap> m:=NewMatrix(IsPlistMatrixRep,Rationals,2,[-1,-2,0,-4]);;
gap> Print(DisplayString(m));
<a mutable 2x2-matrix over Rationals [
[-1 -2]
[0 -4]
]>

@ChrisJefferson
Copy link
Contributor

While I realise this would require significantly changing how your code is structured, one way to fix the "numbers of different length" would be to first make a 2d array of strings representing what you are going to print, then finding the maximum length of a string in that 2d array, and finally printing. Nicely formatting is going to require going over the matrix twice whatever you do (first time to get length, second time to output).

@fingolfin
Copy link
Member

You could also take a look PrintArray and either just call that, or take inspiration from that code.

@danielrademacher
Copy link
Contributor Author

danielrademacher commented Nov 4, 2022

You could also take a look PrintArray and either just call that, or take inspiration from that code.

Thanks a lot! The PrintArray code inspired me to write this new version. 😁

@ChrisJefferson
Copy link
Contributor

Just checking, what's the state of this PR, does it want reviewing?

I don't mind if you are still working on it, just didn't want it to get ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gapdays2022-summer Issues and PRs that arose at https://www.gapdays.de/gapdays2022-summer
Projects
None yet
3 participants