mersenneforum.org  

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

Reply
 
Thread Tools
Old 2010-12-02, 18:31   #1926
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
Great! Add it.

You may also want to register on RC so that your contributions show up under your name (or rather your chosen pseudonym) instead of under your IP address.
maybe I'm having one difficulty for the file read:

Code:
read_file_completely(file)= a=Vec(Str(read(file)));for(x=1,#a,print(a[x]))
if I don't go " before a path the : makes it end , if I do use " before and after it says variable name expected.

when i then use, p="E:\\output.txt" it gives me *** error opening input file: E:\output.txt if we can get around that it's home free. doh i know why i deleted that file lol.

Code:
(14:35) gp > read_file_completely(p="E:\\modulo.txt")
369369369369369369369369369369
now we are getting somewhere as that is a line in the file, however not the first.

Last fiddled with by science_man_88 on 2010-12-02 at 18:37
science_man_88 is offline   Reply With Quote
Old 2010-12-02, 18:33   #1927
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
http://rosettacode.org/wiki/Conditional_structures

this one is a long list lol;

addhelp alias allocatemem apply break default error extern for fordiv forell forprime forstep forsubgroup forvec getheap getrand getstack gettime global if input install kill local my
next print print1 printp printp1 printtex quit read readvec return select setrand system
trap type until whatnow while write write1 writebin writetex
Hmm. I wouldn't consider break a conditional structure, although it can be used with them. I don't think the page counts loops, although you're certainly right that they are actually conditional. kill and next aren't conditional in similar fashion to break.

That leaves if and maybe trap. You could also add && and || (or their short forms & and |) because they short-circuit:
1&print("this happens");
0&print("this doesn't");
CRGreathouse is offline   Reply With Quote
Old 2010-12-02, 18:41   #1928
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
when i then use, p="E:\\output.txt" it gives me *** error opening input file: E:\output.txt if we can get around that it's home free. doh i know why i deleted that file lol.
You might be able to make that work by reversing \ and /, I'm not sure.

But I think this task is not solvable because GP evaluates the contents of the file so two files that are different but evaluate to the same thing can't be distinguished.
CRGreathouse is offline   Reply With Quote
Old 2010-12-02, 19:13   #1929
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

100000110000002 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
You might be able to make that work by reversing \ and /, I'm not sure.

But I think this task is not solvable because GP evaluates the contents of the file so two files that are different but evaluate to the same thing can't be distinguished.
I know what messes it up control characters like enter. If I straighten the file to one line it read it all if not it only evaluated the last line.

though 0 seemed to mess it up as well if all numerical.if we can get past that, and I have an idea how,but I don't know how slow it would be.

Last fiddled with by science_man_88 on 2010-12-02 at 19:17
science_man_88 is offline   Reply With Quote
Old 2010-12-02, 19:35   #1930
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
I know what messes it up control characters like enter. If I straighten the file to one line it read it all if not it only evaluated the last line.

though 0 seemed to mess it up as well if all numerical.if we can get past that, and I have an idea how,but I don't know how slow it would be.
I'm not talking about escaping the backslashes
"c:\\documents and settings\\foo\\bar.gp"
but about replacing them with slashes, which as it happens do not need to be escaped:
"c:/documents and settings/foo/bar.gp"

This is, as I understand, an artifact of the system (cygwin? mingw?) that underlies the Windows version of GP.
CRGreathouse is offline   Reply With Quote
Old 2010-12-02, 19:38   #1931
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
I'm not talking about escaping the backslashes
"c:\\documents and settings\\foo\\bar.gp"
but about replacing them with slashes, which as it happens do not need to be escaped:
"c:/documents and settings/foo/bar.gp"

This is, as I understand, an artifact of the system (cygwin? mingw?) that underlies the Windows version of GP.
I'm not talking in the file name I'm talking in the file if we can remove things like enters and 0's we could do it I think. The enters can be done with deleting the last line and repeated reading it into a Vec. For the 0's i was thinking of appending something on the front of each line then getting rid of it later but that's not so helpful.

Last fiddled with by science_man_88 on 2010-12-02 at 19:39
science_man_88 is offline   Reply With Quote
Old 2010-12-02, 20:12   #1932
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
I'm not talking in the file name I'm talking in the file if we can remove things like enters and 0's we could do it I think. The enters can be done with deleting the last line and repeated reading it into a Vec. For the 0's i was thinking of appending something on the front of each line then getting rid of it later but that's not so helpful.
So all you have to do is read in the file, change the... wait...
CRGreathouse is offline   Reply With Quote
Old 2010-12-02, 20:15   #1933
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
So all you have to do is read in the file, change the... wait...
entire contents

however if i load individual lines in and replace the enters and 0's when I'm done I did get the entire contents lol.
science_man_88 is offline   Reply With Quote
Old 2010-12-02, 20:22   #1934
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

597910 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
entire contents

however if i load individual lines in and replace the enters and 0's when I'm done I did get the entire contents lol.
1. Not good enough; if you have to do something this means GP isn't doing it on its own.
2. You wouldn't get the contents of the file but the contents of the edited file; you'd need to remember what you changed and change it back. This would probably be very hard to do.
CRGreathouse is offline   Reply With Quote
Old 2010-12-02, 20:26   #1935
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

20C016 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
1. Not good enough; if you have to do something this means GP isn't doing it on its own.
2. You wouldn't get the contents of the file but the contents of the edited file; you'd need to remember what you changed and change it back. This would probably be very hard to do.
the enters are easy the 0's are the hard part.

Code:
(16:28) gp > read_file_completely(file)= b=[];a=eval(Vec(Str(read(file))));b=concat(a,b);
(16:28) gp > read_file_completely("e:\\modulo.txt")
%279 = [3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6, 9]
also I can get the file up back in full i believe. I'd do it in the script lol.

Last fiddled with by science_man_88 on 2010-12-02 at 20:28
science_man_88 is offline   Reply With Quote
Old 2010-12-02, 20:48   #1936
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

838410 Posts
Default

on another script:

http://rosettacode.org/wiki/Day_of_the_week

is in the can't be done etc. but:

http://rosettacode.org/wiki/Five_weekends

in the to do list would use it.
science_man_88 is offline   Reply With Quote
Reply

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

All times are UTC. The time now is 22:56.


Fri Aug 6 22:56:11 UTC 2021 up 14 days, 17:25, 1 user, load averages: 4.39, 4.22, 4.01

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.