![]() |
|
|
#1981 | |
|
Aug 2006
3·1,993 Posts |
Quote:
{{mylang|PHP|rank neophyte}} {{mylang|JavaScript|I once knew this, but not anymore.}} if you like. |
|
|
|
|
|
|
#1982 |
|
"Forget I exist"
Jul 2009
Dumbassville
203008 Posts |
then I'm idiot second class lol
|
|
|
|
|
|
#1983 |
|
Aug 2006
597910 Posts |
You can even do
{{mylang|Python|I'd love to learn this some day.}} |
|
|
|
|
|
#1984 | |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Quote:
{{mylangbegin}} {{mylang|PARI/GP|intermediate}} {{mylang|x86 assembly|beginner}} {{mylang|HTML|idiot}} {{mylang|PHP|can't find the ini to start}} {{mylang|C|tried, should get a compiler again unless notepad++ will work}} {{mylang|Javascript|forgotten}} {{mylang|CSS|have a book on it as well as many others}} {{mylangend}} |
|
|
|
|
|
|
#1985 |
|
Aug 2006
3·1,993 Posts |
So post it. (You might also order the languages somehow, maybe alphabetically?)
|
|
|
|
|
|
#1986 | |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Quote:
programming books i have include: Advanced MS-dos:the microsoft guide for assembly language and C programmers (copyright 1986) Beginning programming all in one desk reference for dummies (copyright 2008)<- syntax basics with examples in 15 languages I think. The art of assembly language 2nd edition ( copyright 2010) Dynamic HTML the definitive reference (last copyright 2007) Advanced programming in the unix environment (messed up looking for C books in windows;copyright 2003) Last fiddled with by science_man_88 on 2010-12-03 at 22:00 |
|
|
|
|
|
|
#1987 | |
|
Mar 2006
Germany
55348 Posts |
Quote:
All those tasks from here are marked (by whom?) not doable in PARI but I don't think so. I decided to install PARI/GP (I used first V2.3.4 but noticed it doesn't recognize 'my'-blocks, but 'local'). After some small examples I installed the newer V2.4.2 and begun to play around and read some docs and understanding some examples. Now here's the solution of the above task "Day of the week": Code:
JulianDate(YYYY,MM,DD)={
my(a=0, b=0, Y=YYYY, M=MM);
if(MM < 3, Y--; M+=12);
a=floor(Y/100);
b=2-a+floor(a/4);
if(YYYY<=1582 && MM<=10 && DD<=15, b=0);
return(floor(365.25*(Y+4716)) + floor(30.6001*(M+1)) + DD + b - 1524.5);
}
DayOfWeek(JD)={
my(DayName=["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]);
return(DayName[floor(divrem(JD+0.5,7)[2])+1]);
}
Day_of_the_week={
my(year);
for(year=2008,2121,
if(DayOfWeek(JulianDate(year,12,25))=="Sunday",print(year)));
}
The function "JulianDate" returns this day-counter from the input of year, month and day. Next step is to determine the day of the week by getting the value JulianDate MOD 7. This value is '0' for a Monday, '1' for a Tuesday and so on. The function "DayOfWeek" returns the string of this value. The third part is the task which finds the years, for which the 25. of December is a Sunday for the years from 2008 to 2121. This is my first PARI code so perhaps someone can find any issue or could improve it. Note: I think, no, I know the other two tasks (Date format, Date manipulation) are also doable now. |
|
|
|
|
|
|
#1988 | |
|
Aug 2006
3×1,993 Posts |
Quote:
The description says: These tasks are not generally counted toward "unimplemented", as somebody, somewhere, decided that PARI/GP was inappropriate for these tasks, or implementations of them would be unenlightening. Feel free to try your hand at them anyway.For some tasks, like this one, I thought that the task was doable but would be unenlightening. (In principle, all tasks are doable: create a vector representing an assembly program, convert it to a string with Strchr, write it to a file, and execute it with system().) But as the description says, feel free to ignore the {{omit}} and add the task -- I certainly won't mind. (Ideally, if you do add it, you would remove the {{omit|PARI/GP}} line at the bottom.) |
|
|
|
|
|
|
#1990 | ||
|
Aug 2006
135338 Posts |
Quote:
![]() Quote:
* You certainly don't need to, but sometimes it's nicer to write Code:
square(x)={
x^2
};
Code:
square(x)={
return(x^2);
};
Last fiddled with by CRGreathouse on 2010-12-04 at 05:21 |
||
|
|
|
|
|
#1991 | |
|
Mar 2006
Germany
22·727 Posts |
Quote:
I've not yet read much about the special cases of PARI, so for example the 'return' I did is more from others languages they do this. The "foo>>2" shift (like a division by a power of 2) is like in C but I don't want to use it to be more closer to the algorithm of the calculation of the Julian Date. The round-part was not in my mind... I have to develop more in PARI first to know all basic parts and how to use. Here's the code with your hints and suggestions: Code:
JulianDate(YYYY,MM,DD)={
my(a=0, b=0, Y=YYYY, M=MM);
if(MM<3, Y--; M+=12);
a=Y\100;
b=2-a+a\4;
if(YYYY<=1582 && MM<=10 && DD<=15, b=0);
floor(365.25*(Y+4716)) + floor(30.6001*(M+1)) + DD + b - 1524.5
};
DayOfWeek(JD)={
my(DayName=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]);
DayName[round(JD)%7+1]
};
Day_of_the_week={
for(year=2008,2121,
if(DayOfWeek(JulianDate(year,12,25))=="Sunday",print(year)));
}
|
|
|
|
|
![]() |
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 |