mersenneforum.org  

Go Back   mersenneforum.org > Math Stuff > Computer Science & Computational Number Theory > PARI/GP

Reply
 
Thread Tools
Old 2010-09-08, 21:53   #1365
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

one more thing worked out and I think I have it for one find replace then it's a matter of vectors i think.
science_man_88 is offline   Reply With Quote
Old 2010-09-08, 21:55   #1366
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Code:
%135 = (string_to_search,string_to_find)->my(s1=Vec(string_to_search),s2=Vec(string_to_find),good);c="";d="";for(i=0,#s1-#s2,good=1;for(j=1,#s2,if(s2[j]!=s1[j+i],good=0;c=concat(c,s1[i+1]);break));if(good,d=concat(c,"loser!");print1(d);c="";i=i+#s2))
(18:51) gp > substring("hello Alex, Good bye Alex","Alex")                                c="";i=i+#s2))
hello loser! Good bye loser!
<s2[j]!=s1[j+i],good=0;c=concat(c,s1[i+1]);break));if(good,d=concat(c,"loser!");print1(d);c="";i=i+#s2))
Ive got to pass it to a full vector now and then get it resubmitting it until all the searches are done lol.
science_man_88 is offline   Reply With Quote
Old 2010-09-08, 22:12   #1367
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

which could be done with a further script part to multi-search with Vec()
science_man_88 is offline   Reply With Quote
Old 2010-09-08, 22:29   #1368
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

It looks like you have it working the way you want.
CRGreathouse is offline   Reply With Quote
Old 2010-09-08, 22:52   #1369
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
It looks like you have it working the way you want.
well I think one more change may help. then you can apply it to Vec of Vec to do find and replace and maybe even a Vec of Vec to call each Vec of Vec to search multiple functions to make it search for ? or do you want me to set up Vec although you want to Use it on your PC it may need them to do multiple searches autonomously.
science_man_88 is offline   Reply With Quote
Old 2010-09-08, 23:01   #1370
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

203008 Posts
Default

Code:
%4 = (string_to_search,string_to_find,string_to_replace_with)->my(s1=Vec(string_to_search),s2=Vec(string_to_find),s3=string_to_replace_with,good);c="";d="";for(i=0,#s1-#s2,good=1;for(j=1,#s2,if(s2[j]!=s1[j+i],good=0;c=concat(c,s1[i+1]);break));if(good,d=concat(c,s3);print1(d);c="";i=i+#s2))
(19:58) gp > FaR("Hello Alex","Alex","loser!")                                              c="";i=i+#s2))
Hello loser!
(19:58) gp >
FaR = Find and Replace
science_man_88 is offline   Reply With Quote
Old 2010-09-08, 23:11   #1371
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Code:
(19:58) gp > primorial=["primorial","prime factorial"]
%5 = ["primorial", "prime factorial"]
(20:06) gp > for(x=2,#primorial,FaR("I want the prime factorial",primorial[x],primorial[1])
  ***   syntax error, unexpected $end, expecting KPARROW or ',' or ')': ...primorial[x],primorial[1])
                                                                                                    ^-
(20:08) gp > for(x=2,#primorial,FaR("I want the prime factorial",primorial[x],primorial[1]))
I want the primorial
showing a way to extend it I made a primorial Vec, I then can say from 2 to # primorial, call FaR and check for them if they are there replace with the first in the Vec.
science_man_88 is offline   Reply With Quote
Old 2010-09-08, 23:22   #1372
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

838410 Posts
Default

Give me Vec with technical names and non technical descriptions and maybe I can try for multiple Vec to check through using a matrix etc.
science_man_88 is offline   Reply With Quote
Old 2010-09-08, 23:53   #1373
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

10 Aug 10, 08:52 PM is my first post on a scriptwriter (page 7) so under a month and with arguments we've figured it out lol.

mostly*

Last fiddled with by science_man_88 on 2010-09-09 at 00:39
science_man_88 is offline   Reply With Quote
Old 2010-09-09, 04:28   #1374
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
Give me Vec with technical names and non technical descriptions and maybe I can try for multiple Vec to check through using a matrix etc.
For what it's worth, here are some recent-ish posts I've made where I've converted a description to Pari code:

http://mymathforum.com/viewtopic.php?f=40&t=14769i
Code:
trinv(n)=(sqrtint(8*n-7)+1)>>1
forprime(p=2,1e9,if(is(p,trinv(p)),print("S_0 = "p", c = "trinv(p))))
http://mymathforum.com/viewtopic.php...15163&start=15
Code:
Cohn(P,a='x)={
   my(d=poldegree(P,a),an=polcoeff(P,d,a),b=0);
   for(i=0,d-1,b=max(b,abs(polcoeff(P,i,a))));
   b=ceil(b/an)+1;
   while(1,
      if(isprime(substpol(P,a,b++)),return(b))
   )
};
addhelp(Cohn, "Cohn(P): If P is an irreducible polynomial, return a proof certificate p; otherwise, infinite loop. Based on Ram Murty 2002.");
http://mymathforum.com/viewtopic.php?f=44&t=14683
Code:
for(n=6000,0,if(isprime(n) && 6000%n==0, print(n)))
forstep(n=6000,0,-1,if(isprime(n) && 6000%n==0, print(n)))
for(n=0,6000,if(isprime(n) && 6000%n==0, print(n)))
forprime(p=0,6000,if(6000%p==0, print(p)))
fordiv(6000,n,if(isprime(n), print(n)))
f=factor(6000)[,1]; for(i=1,#f,print(f[i]))
http://mymathforum.com/viewtopic.php?f=24&t=14446
Code:
step(M)=my(m,MM=matrix(4,4));for(i=1,4,for(j=1,4,m=M[i,j];if(i==4|j==4,MM[i,j]+=m*1087,if(i==3&j==3,MM[i,j]+=425*m,MM[i+1,j+1]+=425*m);MM[i+1,j]+=187*m;MM[i,j+1]+=475*m)));MM
matrix(4,4,x,y,x==1&y==1)
step(%)
http://mymathforum.com/viewtopic.php?f=40&t=13249
Code:
er(n)=my(s=eval(Vec(Str(8*n))),n=0);for(i=1,#s,if(s[i]&s[i]!=8,n=10*n+s[i]));n
err1(n,verbose=0)=my(nn,orig=n);while(nn!=n,nn=n;if(n=er(n)<orig,return()))
for(n=1,1e8,err1(n))
http://mymathforum.com/viewtopic.php?f=40&t=12565
Code:
factorPueo(P = 2009)={
   my(m=1, k=(sqrtint(1+8*P)-1)>>1, NB=k*(k+1)/2, NA=NB+m+k, i);
   \\ m = 1 is a triangle number; solve k*(k1)/2 = P for k
   \\ define two numbers, NB = S(m,k) and NA = S(m,k+1), that bracket P

   while(NB!=P,
      while(NB > P,      \\ is NB too large?
         NA = NB;
         NB -= m + k - 1;
         k -= 1
        );
      while(NA <= P,      \\ is NA too small?
         NB = NA;
         NA += m + k + 1;
         k += 1
      );
      if(NB < P,
         NB += k;      \\ make NB larger using [6] above to increase m
         NA += k + 1;   \\ make NA larger using [7] above to increase m
         m += 1
      )
   );

   i = k;
   if(i%2 == 0,         \\ if k is even, divide by 2 to get factor of P
      i /= 2
   );

   j = P/i;
   print("S("m","k") = "P);
   print(i" * "j" = "i*j);
};
The difficulties of these underscores the scope of your project...

Last fiddled with by CRGreathouse on 2010-09-09 at 04:36
CRGreathouse is offline   Reply With Quote
Old 2010-09-09, 11:39   #1375
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

you're over worked and underpaid.

I've got the basics of math English down with this code though I'll make more list.

if you look at it correcting typo is a task it would need to be AI complete.

the more tasks we need it to do and the more Vec we need to do this the more memory intensive it would be.
science_man_88 is offline   Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do I sometimes see all the <> formatting commands when I quote or edit? cheesehead Forum Feedback 3 2013-05-25 12:56
Passing commands to PARI on Windows James Heinrich Software 2 2012-05-13 19:19
Ubiquity commands Mini-Geek Aliquot Sequences 1 2009-09-22 19:33
64-bit Pari? CRGreathouse Software 2 2009-03-13 04:22
Are these commands correct? jasong Linux 2 2007-10-18 23:40

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


Fri Aug 6 23:11:56 UTC 2021 up 14 days, 17:40, 1 user, load averages: 4.26, 4.21, 4.04

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

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.