mersenneforum.org  

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

Reply
 
Thread Tools
Old 2010-08-24, 21:42   #837
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

597910 Posts
Default

Code:
160074594123956794219458402545764711419701756584167638068329365693034831201396939643913504262352130745852290381939420288140978693341478528259387657797580376902986395224408345354821071590949525350364018649578862749297255505837416439606095853836355923951566526457673735312339184330365326723420347366112675200713878660771081227364603472040699601553789595479339960277304318254798850917751885704667910151149091532150905626179048799036700679933820859845365985390911277048117168671365128451668210581621327277787092273718680191991994664786587234396792965881059281805213980760310898060678555989602303590308736441654087832242397146458759717551025723008092342436218853265799505252096172021953238850043510060599858403400384570222716416699106818277439891613536333361593153540409685328569171314344686601795619300473375554423332099932225456784121921559118525805374656294079430382561204188488274552102452626811652972822901469815861523877416162913528086735710854833100692524526048253371898482177626664655396682221293652089791416114579511127188674154339902564205267260071373223290668469512503977940823503507668484572724611665887674632905471958304064277923482051286050078929
1155 digits.
CRGreathouse is offline   Reply With Quote
Old 2010-08-24, 22:04   #838
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

CRG is there a way to create a Vec(Vec(input())) such that each element is a string if so we can search it word by word instead of letter by letter for something to help you and simply replace one for another.
science_man_88 is offline   Reply With Quote
Old 2010-08-24, 22:23   #839
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
CRG is there a way to create a Vec(Vec(input())) such that each element is a string if so we can search it word by word instead of letter by letter for something to help you and simply replace one for another.
I don't know what you're looking for, exactly, but that sounds inefficient.

What about doing this instead:
Code:
substring(string_to_search, string_to_find)={
  my(s1=Vec(string_to_search),s2=Vec(string_to_find),good);
  for(i=0,#s1-#s2,
    good=1;
    for(j=1,#s2, if(s2[j] != s1[j+i], good=0;break));
    if(good, return(1))
  );
  0
};
Code:
> substring("good day", "day")
%1 = 1
> substring("good day", "night")
%2 = 0
Of course there are better ways to do this, but I wouldn't worry about that until performance is an issue. At that point you can either make it more efficient or you can use a different system entirely.

Last fiddled with by CRGreathouse on 2010-08-24 at 22:25
CRGreathouse is offline   Reply With Quote
Old 2010-08-24, 22:28   #840
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

see instead of returning 1 or 0 I was going to replace the string I found with what Pari can understand. but I'll try it your way for now.
science_man_88 is offline   Reply With Quote
Old 2010-08-24, 22:34   #841
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

is there a way to replace what we find with another string ? if so maybe say if this is found return("stringx") into the string instead.
science_man_88 is offline   Reply With Quote
Old 2010-08-24, 22:46   #842
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
is there a way to replace what we find with another string ? if so maybe say if this is found return("stringx") into the string instead.
Sure, make whatever changes you like.
CRGreathouse is offline   Reply With Quote
Old 2010-08-24, 23:05   #843
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

100000110000002 Posts
Default

I think we can use what we did for shifting to transfer from position j+ length(s2) = to a new Vec then delete the s2 from where it was found concat(newstring) on the new end of it then concat (the rest) back on to the string after adjusting j for the new length of the string so it only checks what it hasn't before. then repeat for other strings. then we can use these names placed in to print the function by name and if we can get it to construct it in the correct manner from there it'll be done except how to read into the s1.
science_man_88 is offline   Reply With Quote
Old 2010-08-24, 23:10   #844
kar_bon
 
kar_bon's Avatar
 
Mar 2006
Germany

22×727 Posts
Default

Why so complicated?

Because it is PARI -> program to calculate mathematic formulas and values or show functions, but not to manipulate texts like search/replace strings and other string-functions!

What you want to create is hard enough to be successful, but using PARI for that is even impossible!

Taking another tool/language would be better! Trust me.

Last fiddled with by kar_bon on 2010-08-24 at 23:11
kar_bon is offline   Reply With Quote
Old 2010-08-24, 23:17   #845
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

20C016 Posts
Default

Quote:
Originally Posted by kar_bon View Post
Why so complicated?

Because it is PARI -> program to calculate mathematic formulas and values or show functions, but not to manipulate texts like search/replace strings and other string-functions!

What you want to create is hard enough to be successful, but using PARI for that is even impossible!

Taking another tool/language would be better! Trust me.
our last conversation on this was post 285 kar_bon up to you if you want the task of writing it in another language meanwhile I'm learning about how to make Pari do work for CRG lol.

Last fiddled with by science_man_88 on 2010-08-24 at 23:17
science_man_88 is offline   Reply With Quote
Old 2010-08-24, 23:18   #846
kar_bon
 
kar_bon's Avatar
 
Mar 2006
Germany

22·727 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
our last conversation on this was post 285 kar_bon up to you if you want the task of writing it in another language meanwhile I'm learning about how to make Pari do work for CRG lol.
Ok, I wish you luck for that task! And patience!
kar_bon is offline   Reply With Quote
Old 2010-08-24, 23:54   #847
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Talking

Worthless analogy of the day:

sm is building what looks like a shed, pounding in nails with a coconut. kar_bon says, "Instead of using that coconut, why not use this hammer?". CRGreathouse says, "Good start, but making a rocketship is hard, even with a hammer." sm says, "You don't get it, I'm building a rocketship with this coconut because I want to get better with coconuts (and because I want a rocketship).".
CRGreathouse 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:08.


Fri Aug 6 23:08:31 UTC 2021 up 14 days, 17:37, 1 user, load averages: 3.94, 3.90, 3.91

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.