On Mon, May 18, 2009 at 1:45 AM, Kwankyu <ekwan...@gmail.com> wrote:
>
> Hi Dan,
>
> On May 18, 5:38 pm, Dan Drake <dr...@kaist.edu> wrote:
>> On Mon, 18 May 2009 at 01:13AM -0700, Kwankyu wrote:
>> > In Magma, there is a handy construct like
>>
>> > [GF(2) | 1,0,1,1]
>>
>> > to get the list with elements in GF(2). Is there a similar one in Sage
>> > or Python?
>>
>> Use list comprehensions:
>>
>>   [GF(2)(x) for x in [1, 0, 1, 1]]
>>
>> They're very flexible:
>>
>>   [GF(2)(x^2) for x in prime_range(5, 25) if Mod(x, 3) == 2]
>>
>
> Yeah, I though of that. But I used the Magma construct a lot. So I
> wanted a similarly quick and short phrase in Sage.  Thank you anyway.
>
> Kwankyu
>

You might want to define your own function, e.g.,

def S(R, s):  return [R(x) for x in s]

then you can do

sage: S(GF(2), [1,0,1,3])
[1, 0, 1, 1]


 -- 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