![]() |
|
|
#2025 | |
|
Mar 2006
Germany
1011010111002 Posts |
Quote:
yours: for(x=1,100000,convert(12345678901234567890,10,16)) done in 19.6 secs mine: for(x=1,100000,convert1("12345678901234567890",10,16)) done in 10.5 secs The main difference is: You're using the power function and I only the multiplication: power: a= x1*b^e1 + x2*b^e2 + x3*b^e3 + .... multiplication: a= ((x1*b + x2)*b + x3 ... |
|
|
|
|
|
|
#2026 | |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Quote:
|
|
|
|
|
|
|
#2027 |
|
Aug 2006
10111010110112 Posts |
No big deal, he knew Horner form and you didn't.
|
|
|
|
|
|
#2028 |
|
"Forget I exist"
Jul 2009
Dumbassville
100000110000002 Posts |
he should put his up, yeah I had no power this morning but it's back up now I'm kinda worried my mom supposedly had hypercapnia last night and they think codeine ( methyl-morphine) may have helped it unsurprising with morphine allergies in the family history. I know more terms than my sisters so I can describe it but I haven't gone in to see her yet. I was told to a few times I'm not sure if I have something, They think the flu shot may have triggered her so hopefully I don't do the same. they haven't given water, I think it's from the fact that unless they give a lot they acidify the blood by production of carbonic acid.
|
|
|
|
|
|
#2029 |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
I think I found something interesting to talk about with the lucaslehmer() axn came up with. Mind if I see what you think ?
Last fiddled with by science_man_88 on 2010-12-06 at 19:43 |
|
|
|
|
|
#2030 |
|
Aug 2006
3×1,993 Posts |
Go for it.
|
|
|
|
|
|
#2031 |
|
"Forget I exist"
Jul 2009
Dumbassville
203008 Posts |
|
|
|
|
|
|
#2032 |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
never mind I see a pattern forming but I bet it's well known.
|
|
|
|
|
|
#2033 |
|
Mar 2006
Germany
22·727 Posts |
Here are some string maipulation functions, because I missed them much:
- String to upper case - String to lower case - Left string - Right string - Mid string Functions like Find or Replace are therefore possible, too. More suggestions: - StrFlip: lower to upper and upper to lower in one string - StrCap: only first character of string/word capitalize - StrTrim: delete spaces from beginning/end of string I think StrReverse or CheckPalindrome were done, right? Code:
addhelp(StrToUp, "StrToUp(str): Convert a string str in upper case.");
StrToUp(str)={
my(sup=Vecsmall(str),s="");
for(n=1,#sup,
if(sup[n]>=97 && sup[n]<=122,
s=concat(s,Strchr(sup[n]=sup[n]-32)),
s=concat(s,Strchr(sup[n])))
);
s
};
addhelp(StrToLow, "StrToLow(str): Convert a string str in lower case.");
StrToLow(str)={
my(sup=Vecsmall(str),s="");
for(n=1,#sup,
if(sup[n]>=65 && sup[n]<=90,
s=concat(s,Strchr(sup[n]=sup[n]+32)),
s=concat(s,Strchr(sup[n])))
);
s
};
addhelp(StrLeft, "StrLeft(str,n): Gives back n characters from left of string str.");
StrLeft(str,n)={
my(strh=Vecsmall(str),s="");
if(n<1, return(s)); \\ n too small: return empty string
if(n>=#strh, return(str)); \\ n to big: return str
for(x=1,n,
s=concat(s,Strchr(strh[x]))
);
s
};
addhelp(StrRight, "StrRight(str,n): Gives back n characters from right of string str.");
StrRight(str,n)={
my(strh=Vecsmall(str),s="");
if(n<1, return(s)); \\ n too small: return empty
if(n>#strh, return(str)); \\ n too big: return str
for(x=#strh-n+1,#strh,
s=concat(s,Strchr(strh[x]))
);
s
};
addhelp(StrMid, "StrMid(str,n,m): Gives back m characters from position n of string str.");
StrMid(str,n,m)={
my(strh=Vecsmall(str),s="");
if(n<1, n=1); \\ n too small: set n=start of string
if(n>#strh, return(s)); \\ n too big: return empty string
if(n+m>#strh, m=#strh-n+1); \\ m too big: set m maximum length available
for(x=n,n+m-1,
s=concat(s,Strchr(strh[x]))
);
s
};
- The expression "sup[n]=sup[n]+32" won't work with "sup[n]+=32" ! - Typing in characters like German Umlaute are not allowed/not doable in PARI! Last fiddled with by kar_bon on 2010-12-07 at 01:05 |
|
|
|
|
|
#2034 |
|
"Forget I exist"
Jul 2009
Dumbassville
838410 Posts |
So is FaR lol
Last fiddled with by science_man_88 on 2010-12-07 at 01:06 |
|
|
|
|
|
#2035 | |
|
Aug 2006
3·1,993 Posts |
Quote:
Code:
> v=vector(3,n,n);v[2]+=10;v %1 = [1, 12, 3] > v=vectorsmall(3,n,n);v[2]+=10;v %2 = Vecsmall([1, 12, 3]) |
|
|
|
|
![]() |
| Thread Tools | |
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 |