I think I do understand what Armand is asking.  Let's see:

Say I have been using Magma for half an hour.  I typed lots of stuff,
including typos etc, and a whole lot of output has scrolled past.  Now
I want to keep all the commands that I typed, put them in a file,
sanitize them, ans use them later as a kind of script.  I can do that
in Magma like this:

> 2+2;
4
> Factor(x^2-1);

>> Factor(x^2-1);
         ^
Runtime error in 'Factor': Bad argument types
Argument types given: RngUPolElt[FldRat]

> R<x>:=PolynomialRing(Rationals());
> Factor(x^2-1);

>> Factor(x^2-1);
         ^
Runtime error in 'Factor': Bad argument types
Argument types given: RngUPolElt[FldRat]

> Factorization(x^2-1);
[
    <x - 1, 1>,
    <x + 1, 1>
]
> %S
SetSeed(2266693670, 0); 2+2;
Factor(x^2-1);
R<x>:=PolynomialRing(Rationals());
Factor(x^2-1);
Factorization(x^2-1);

(deliberately full of beginner's mistakes!).

Now I think that Armand wants an equivalent to %S.  Presumably the
commands typed in will all be in a history file somewhere.

I may be wrong, of course!

John

On Apr 3, 4:15 am, William Stein <wst...@gmail.com> wrote:
> On Thu, Apr 2, 2009 at 8:04 PM, ARMAND BRUMER <bru...@fordham.edu> wrote:
> > Dera William,
>
> > Thanks for the detailed answer. Unfortunately, I am dealing with collections
> > of many tens of thousands of "curves". I was able to load them into sage
> > with
>
> > load /Users/armandbrumer/sage/TORNOTSS6short.sage
>
> > I want to  reverse the process after using sage to modify the lists, for
> > instance by using liu's program.
>
> > If I understand you properly, there is no simple analogous command to save
> > my list of lists in text format.  So, what I need can  be done only by
> > changing the data to strings and then saving those strings...
>
> I'm still not sure what you're asking, but if you want to save objects
> (in a binary compressed format), in Sage you can save almost any data
> structure to disk, and load it back.  For this, the situation
> regarding this is *VASTLY BETTER* in Sage than it is in Magma.   The
> command that does this is simply called "save".  Here are some
> examples:
>
>             sage: a = matrix(2, [1,2,3,-5/2])
>             sage: save(a, 'test.sobj')
>             sage: load('test.sobj')
>             [   1    2]
>             [   3 -5/2]
>
> Here's an example involving starting with the curves of conductor up
> to 100 in Cremona, saving the list of them, loading it back into a new
> session, changing something about one, saving the list again, then
> loading that back and verifying that the change was saved:
>
> sage: E = list(cremona_curves([1..100]))
> sage: len(E)
> 306
> sage: save(E, 'E.sobj')
> sage:
> Exiting SAGE (CPU time 0m1.48s, Wall time 1m0.36s).
> D-69-91-159-158:tmp wstein$ sage
> ----------------------------------------------------------------------
> | Sage Version 3.4, Release Date: 2009-03-11                         |
> | Type notebook() for the GUI, and license() for information.        |
> ----------------------------------------------------------------------
> sage: E = load('E.sobj')
> sage: len(E)
> 306
> sage: E[0].armand = 'brumer'
> sage: save(E, 'E.sobj')
> sage:
> Exiting SAGE (CPU time 0m0.32s, Wall time 0m17.92s).
> D-69-91-159-158:tmp wstein$ sage
> ----------------------------------------------------------------------
> | Sage Version 3.4, Release Date: 2009-03-11                         |
> | Type notebook() for the GUI, and license() for information.        |
> ----------------------------------------------------------------------
> sage: E = load('E.sobj')
> sage: E[0].armand
> 'brumer'
>
> When it comes to lists of lists, here is an example both of saving to
> an sobj (compressed binary format) and saving to plain text:
>
> sage: E = list(cremona_curves([1..100]))
> sage: v = [e.a_invariants() for e in E]
> sage: v[:3]
> [[0, -1, 1, -10, -20], [0, -1, 1, -7820, -263580], [0, -1, 1, 0, 0]]
> sage: save(v,'v.sobj')
> sage: len(load('v.sobj'))
> 306
> sage: open('v.txt','w').write(str(v))
> sage: open('v.txt').read()[:300]
> '[[0, -1, 1, -10, -20], [0, -1, 1, -7820, -263580], [0, -1, 1, 0, 0],
> [1, 0, 1, 4, -6], [1, 0, 1, -36, -70], [1, 0, 1, -171, -874], [1, 0,
> 1, -1, 0], [1, 0, 1, -2731, -55146], [1, 0, 1, -11, 12], [1, 1, 1,
> -10, -10], [1, 1, 1, -135, -660], [1, 1, 1, -5, 2], [1, 1, 1, 35,
> -28], [1, 1, 1, -2160, -39540'
> sage: vv = sage_eval(open('v.txt').read())
> sage: vv == v
> True
>
> William
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to