mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   PARI/GP (https://www.mersenneforum.org/forumdisplay.php?f=155)
-   -   PARI's commands (https://www.mersenneforum.org/showthread.php?t=13636)

CRGreathouse 2010-11-29 01:24

[QUOTE=science_man_88;239117]okay thanks now we can use your brains to finish both long multiply and determine if numerical.[/QUOTE]

I'd rather expand yours. :smile:

science_man_88 2010-11-29 01:45

[QUOTE=CRGreathouse;239118]I'd rather expand yours. :smile:[/QUOTE]

Good luck with that lol.

[CODE]longmultiply(a,b)= c=eval(Vec(Str(a)));d=eval(Vec(Str(b)));carry=0;answer=[];forstep(x=#d,1,[-1],forstep(y=#c,1,[-1],answer=concat(((c[y]*d[x])+carry)%10,answer);carry=floor((c[y]*d{x])/10))
*** sorry, embedded braces (in parser) is not yet implemented.[/CODE]

I can't figure out what's messing up and, Yes I've checked the braces just enough that it should work. Oh never mind stupid concat lol.

didn't work for calculating it before either.

science_man_88 2010-11-29 02:00

I have a hard time believing [url=http://rosettacode.org/wiki/Pascal's_triangle]this[/url] hasn't been done.

CRGreathouse 2010-11-29 02:10

[QUOTE=science_man_88;239122]Good luck with that lol.[/QUOTE]

It's already worked. Look at how much you can do with Pari now -- you hadn't even heard of it a year ago.

[QUOTE=science_man_88;239122]I can't figure out what's messing up and, Yes I've checked the braces just enough that it should work. Oh never mind stupid concat lol.[/QUOTE]

You wrote "{x]" instead of "[x]".

CRGreathouse 2010-11-29 02:13

[QUOTE=science_man_88;239123]I have a hard time believing [url=http://rosettacode.org/wiki/Pascal's_triangle]this[/url] hasn't been done.[/QUOTE]

Essentially the only tasks that are done are the ones I did over the last four weeks. Sometimes I didn't do a task because it was easy and I thought anyone could do it; sometimes I left a task because I couldn't think of any nice way to do it; sometimes I couldn't think of any way to do it; sometimes I just didn't get around to it.

You may very well become the #2 Pari contributor on RC if you continue this way. (I don't know who presently has that title, but they couldn't have very many.)

science_man_88 2010-11-29 02:25

[QUOTE=CRGreathouse;239126]Essentially the only tasks that are done are the ones I did over the last four weeks. Sometimes I didn't do a task because it was easy and I thought anyone could do it; sometimes I left a task because I couldn't think of any nice way to do it; sometimes I couldn't think of any way to do it; sometimes I just didn't get around to it.

You may very well become the #2 Pari contributor on RC if you continue this way. (I don't know who presently has that title, but they couldn't have very many.)[/QUOTE]

Yeah something missing in my code I know because answer became

[CODE][6, 9, 4, 6][/CODE]

instead of [CODE][7,3,6][/CODE]

CRGreathouse 2010-11-29 02:32

Well, good luck debugging. Sometimes splitting the program into multiple functions helps, as does adding diagnostic messages with print(). (You remove these after debugging, of course.)

I finished the Amb task, that was a pain to debug. I hate string processing in Pari. :smile:

science_man_88 2010-11-29 02:33

[QUOTE=CRGreathouse;239129]

I finished the Amb task, that was a pain to debug. I hate string processing in Pari. :smile:[/QUOTE]

Really? I thought it was only me that hated it. I'm heading to bed I'm up 30 minutes past when I usually go to bed. I've got Pari still open and I'm semi working on a pascals triangle script.

CRGreathouse 2010-11-29 02:38

[QUOTE=science_man_88;239130]Really? I thought it was only me that hated it. I'm heading to bed I'm up 30 minutes past when I usually go to bed. I've got Pari still open and I'm semi working on a pascals triangle script.[/QUOTE]

The problem I had was related to the power of concat: I wanted it to join together two vectors and it was obligingly smushing them into strings. I managed to solve my problem, thankfully.

science_man_88 2010-11-29 12:22

[QUOTE=CRGreathouse;239131]The problem I had was related to the power of concat: I wanted it to join together two vectors and it was obligingly smushing them into strings. I managed to solve my problem, thankfully.[/QUOTE]

the problem for me is I don't use multiple answer vectors:

023
x32
___
0046
+690

not :

23*32 =[6,9,4,6]

CRGreathouse 2010-11-29 14:27

[QUOTE=science_man_88;239157]the problem for me is I don't use multiple answer vectors:

023
x32
___
0046
+690

not :

23*32 =[6,9,4,6][/QUOTE]

Ah. You should only use one, but pre-set it to the appropriate size, filled with 0s, then *add* rather than concatenate. That way you can go from

[0, 0, 0, 0, 0]
to
[0, 0, 0, 0, 6]
to
[0, 0, 0, 4, 6]
to
[0, 0, 0, 13, 6]
to
[0, 0, 6, 13, 6]
which can be simplified to
[0, 0, 7, 3, 6]
and then
[7, 3, 6]
if desired.


All times are UTC. The time now is 23:11.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.