Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #83490

Re: Decimals and other numbers

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jeanpierreda@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.104
X-Spam-Level *
X-Spam-Evidence '*H*': 0.79; '*S*': 0.00; '(of': 0.07; 'seemed': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'jan': 0.12; 'assume': 0.14; 'arbitrary.': 0.16; 'multiplied': 0.16; 'nonempty': 0.16; 'wrote:': 0.18; 'rules': 0.22; 'cc:addr:python.org': 0.22; 'integer': 0.24; 'regardless': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; '???': 0.30; 'message-id:@mail.gmail.com': 0.30; 'subject:numbers': 0.31; 'subject:other': 0.31; 'fri,': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'too': 0.37; 'list': 0.37; 'clear': 0.37; 'list,': 0.38; 'pm,': 0.38; 'that,': 0.38; 'anything': 0.39; 'itself': 0.39; 'how': 0.40; 'even': 0.60; 'liked': 0.60; 'full': 0.61; 'course': 0.61; 'times': 0.62; 'kind': 0.63; 'choose': 0.64; 'our': 0.64; 'therefore,': 0.64; 'products,': 0.74; '2015': 0.84; 'explanation:': 0.84; 'no:': 0.84; 'factors': 0.97
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Xo+8+V94v6MW0/JbiNKcR/9+WEfE9oNg+lGt6mv/g/c=; b=euqIPGZxYof+r81GRcJfn84Gg59SK6OEgtRWaJ+BQ/wARc0eGYwyqc49CLPL6pvqGK J0+CxUWGmBjY0vs4MaLKq/rGH1M8Ygk93bAxY1WZKCo27Dt0Eri6V3Vuk9IDgACWzxyf R4iBRgj003P5Qi4U2hZFEddPB4fcp4CgI4XPsioeDiDS8sy1VdCtybHViTFHJEidPhIY HD27i8J1hl0RIqz09u5TfbOh+HQ8uc7Fzk5sUM9TL7bile8nmIEixkyFFuh3ahjdzhLy 9lSpK8pO3797dLQRMyPnRSt7zEj/udpt49oI+jWdDJByfLZhfVC4FnzeyOc4EHjzreDP QMRw==
X-Received by 10.224.131.70 with SMTP id w6mr23893643qas.78.1420862281650; Fri, 09 Jan 2015 19:58:01 -0800 (PST)
MIME-Version 1.0
In-Reply-To <chbj8eF76b8U1@mid.individual.net>
References <CABicbJK-5izGtet8BsS1Yqx+6AHMX7gLU4zYjjt5jULJXNVipA@mail.gmail.com> <54AF405C.6020609@davea.name> <mailman.17501.1420772593.18130.python-list@python.org> <54af9612$0$12995$c3e8da3$5496439d@news.astraweb.com> <chbj8eF76b8U1@mid.individual.net>
From Devin Jeanpierre <jeanpierreda@gmail.com>
Date Fri, 9 Jan 2015 19:57:20 -0800
Subject Re: Decimals and other numbers
To Gregory Ewing <greg.ewing@canterbury.ac.nz>
Content-Type text/plain; charset=UTF-8
Cc "comp.lang.python" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.17552.1420862283.18130.python-list@python.org> (permalink)
Lines 44
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1420862283 news.xs4all.nl 2894 [2001:888:2000:d::a6]:57853
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:83490

Show key headers only | View raw


On Fri, Jan 9, 2015 at 7:05 PM, Gregory Ewing
<greg.ewing@canterbury.ac.nz> wrote:
> It's far from clear what *anything* multiplied by
> itself zero times should be.
>
> A better way of thinking about what x**n for integer
> n means is this: Start with 1, and multiply it by
> x n times. The result of this is clearly 1 when n
> is 0, regardless of the value of x.
>
>> 5**4 = 5*5*5*5 = 625
>
> No:
>
> 5**4 = 1*5*5*5*5
> 5**3 = 1*5*5*5
> 5**2 = 1*5*5
> 5**1 = 1*5
> 5**0 = 1

I never liked that, it seemed too arbitrary. How about this explanation:

Assume that we know how to multiply a nonempty list numbers. so
product([a]) == a, product([a, b]) = a * b, and so on.

def product(nums):
    if len(nums) == 0:
        return ???
    return reduce(operator.mul, nums)

It should be the case that given a list of factors A and B,
product(A + B) == product(A) * product(B)   (associativity).
We should let this rule apply even if A or B is the empty list,
otherwise our rules are kind of stupid.

Therefore, product([] + X) == product([]) * product(X)
But since [] + X == X, product([] + X) == product(X)

There's only one number like that: product([]) == 1

(Of course if you choose not to have the full associativity rule for
empty products, then anything is possible.)

-- Devin

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: Decimals and other numbers Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-01-08 19:02 -0800
  Re: Decimals and other numbers Marko Rauhamaa <marko@pacujo.net> - 2015-01-09 09:28 +0200
    Re: Decimals and other numbers Chris Angelico <rosuav@gmail.com> - 2015-01-09 18:37 +1100
      Re: Decimals and other numbers Marko Rauhamaa <marko@pacujo.net> - 2015-01-09 11:31 +0200
    Re: Decimals and other numbers Dave Angel <davea@davea.name> - 2015-01-09 02:49 -0500
    Re: Decimals and other numbers Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-01-09 00:51 -0800
      Re: Decimals and other numbers Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2015-01-09 11:07 +0200
        [OT] x**y == y**x Peter Pearson <pkpearson@nowhere.invalid> - 2015-01-09 17:46 +0000
          Re: [OT] x**y == y**x Marko Rauhamaa <marko@pacujo.net> - 2015-01-09 23:41 +0200
            Re: [OT] x**y == y**x Peter Pearson <pkpearson@nowhere.invalid> - 2015-01-10 16:57 +0000
  Re: Decimals and other numbers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-09 19:49 +1100
    Re: Decimals and other numbers Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-01-09 00:58 -0800
      Re: Decimals and other numbers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-09 21:20 +1100
        Re: Decimals and other numbers Chris Angelico <rosuav@gmail.com> - 2015-01-09 21:39 +1100
          Re: Decimals and other numbers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-09 23:24 +1100
            Re: Decimals and other numbers Chris Angelico <rosuav@gmail.com> - 2015-01-09 23:34 +1100
        Re: Decimals and other numbers Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-01-09 17:25 -0800
        Re: Decimals and other numbers Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-01-10 16:08 +1300
    Re: Decimals and other numbers Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-01-09 01:11 -0800
    Re: Decimals and other numbers Marko Rauhamaa <marko@pacujo.net> - 2015-01-09 11:34 +0200
      Re: Decimals and other numbers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-09 22:03 +1100
    Re: Decimals and other numbers Marko Rauhamaa <marko@pacujo.net> - 2015-01-09 11:44 +0200
    Re: Decimals and other numbers Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-01-10 16:05 +1300
      Re: Decimals and other numbers Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-01-09 19:57 -0800

csiph-web