Alastair,
Thanks a lot.
the Pytonic way:
def Ppulse(mesures):
return [N((l[0]-l[1]),12) for l in mesures]
works(I shall need to understand/study why!!)
The other solution:
def Ppulse(mesures):
result=[]
for k,l in enumerate(mesures)
result.append(N((l[0]-l[1]),12))
gives a syntax error(most certainly my mistake, but what?)
>#Why are you using enumerate here, as you don't use k?
I use k in another step of the program.
Thanks again.
Claude.
On Mar 25, 8:24 am, Alastair Irving <[email protected]>
wrote:
> On 25/03/2011 13:15, clodemil wrote:> Hi all,
>
> > Here is a list:
>
> > mesures=[[172,91,57],[181,88,58],[146,88,56],[191,85,59],[171,92,50],
> > [157,93,55],[180,84,48],[142,77,60],[169,80,45],[162,76,59],
> > [167,104,73],[166,81,53],[145,78,59],[163,98,58],[192,90,50],
> > [184,85,60],[151,77,56]]
> > # [[P systolic,P diastolic,Pulse rate]]
>
> > and a function
>
> There's at least two ways of modifying this. You could either append to
> a list as you go along:
>
> > def Ppulse(mesures):
>
> results=[]
> #Why are you using enumerate here, as you don't use k?> for k,l in
> enumerate(mesures):
>
> result.append(N((l[0]-l[1]),12))
>
> > print N((l[0]-l[1]),12)
> > # Pulse Pressure = Psys - Pdia
>
> Or, a more Pythonic way of doing this would be with a list comprehension:
>
> def Pulse(measures): return [N((l[0]-l[1]),12) for l in measures]
>
> I hope this helps
>
> Alastair
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org