Bill Allombert on Sun, 22 Jan 2017 23:06:52 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Question on printing a matrix...


On Sun, Jan 22, 2017 at 03:50:14PM -0600, wraithx@morpheus.net wrote:
> Is there a way to print a matrix that looks as nice as when you view it on
> the gp command line?
> 
> For example, if I do:
> (15:43) gp > a=factor(12)
> %13 =
> [2 2]
> 
> [3 1]
> 
> (15:43) gp > a
> %14 =
> [2 2]
> 
> [3 1]
> 
> (15:43) gp > print(a)
> [2, 2; 3, 1]
> 
> I'd like to "print" that matrix and get the same output as just doing "a" on
> the command line.  Is there a way to do this?  For more information, I'll be
> doing this inside of a function.  When I just put:
> a;
> on its own line, I do not get any output on the screen.  When I do:
> print(a);
> I get the output shown last above.  I'd like to get the %14 output to happen
> inside that function.  Is this possible?

There used to be a function printp, but it has been removed.
You can try that instead:

? printf("%d", factor(12));
[2 2]

[3 1]

Or
? printm(M)=apply(s->print(s),Col(M));print1()
[2, 2]
[3, 1]

Cheers,
Bill.