lambda with floats

Albert van der Horst albert at spenarnc.xs4all.nl
Thu Apr 15 17:55:00 CEST 2010


In article <3790faeb-ae4c-4b45-b0a6-41cb32e46e41 at k13g2000yqe.googlegroups.com>,
Patrick Maupin  <pmaupin at gmail.com> wrote:
>On Apr 6, 11:10=A0pm, Patrick Maupin <pmau... at gmail.com> wrote:
>> On Apr 6, 11:04=A0pm, Patrick Maupin <pmau... at gmail.com> wrote:
>>
>>
>>
>> > On Apr 6, 10:16=A0pm, monkeys paw <mon... at joemoney.net> wrote:
>>
>> > > I have the following acre meter which works for integers,
>> > > how do i convert this to float? I tried
>>
>> > > return float ((208.0 * 208.0) * n)
>>
>> > > =A0>>> def s(n):
>> > > ... =A0 =A0 return lambda x: (208 * 208) * n
>> > > ...
>> > > =A0>>> f =3D s(1)
>> > > =A0>>> f(1)
>> > > 43264
>> > > =A0>>> 208 * 208
>> > > 43264
>> > > =A0>>> f(.25)
>> > > 43264
>>
>> > Not sure why you are returning a lambda (which is just a function that
>> > does not have a name) from an outer function.
>>
>> > A function that does this multiplication would simply be:
>>
>> > def s(n):
>> > =A0 =A0 return 208.0 * 208.0 * n
>>
>> > Regards,
>> > Pat
>>
>> I realized I didn't show the use. =A0A bit different than what you were
>> doing:
>>
>> >>> def s(n):
>>
>> ... =A0 =A0 return 208.0 * 208.0 * n
>> ...>>> s(1)
>> 43264.0
>> >>> s(0.5)
>> 21632.0
>> >>> s(3)
>>
>> 129792.0
>>
>> I'm not sure exactly what you mean by "acre meter" though; this
>> returns the number of square feet in 'n' acres.
>>
>> Regards,
>> Pat
>
>I should stop making a habit of responding to myself, BUT.  This isn't
>quite an acre in square feet.  I just saw the 43xxx and assumed it
>was, and then realized it couldn't be, because it wasn't divisible by
>10.  (I used to measure land with my grandfather with a 66 foot long
>chain, and learned at an early age that an acre was 1 chain by 10
>chains, or 66 * 66 * 10 =3D 43560 sqft.)
>That's an exact number, and 208 is a poor approximation of its square
>root.

208 = 2^6 * 13^2

66 = 2 * 3 * 11

Now I understand why the state of Wisconsin wants to drop out of
the USA and join the EU ;-)

>
>Regards,
>Pat

Groetjes Albert

--
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst




More information about the Python-list mailing list