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


Groups > comp.lang.python > #87482

Re: More or less code in python?

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <joel.goldstick@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'odd': 0.07; 'subject:code': 0.07; 'runs': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'doing,': 0.16; 'formatted': 0.16; 'guessing': 0.16; 'less,': 0.16; 'subject:More': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'skip:{ 20': 0.24; 'question': 0.24; 'cc:2**0': 0.24; '15,': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'generally': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; 'lines': 0.31; 'url:python': 0.33; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'two': 0.37; 'server': 0.38; 'pm,': 0.38; 'url:mail': 0.40; 'browser': 0.61; 'mar': 0.68; '");': 0.84; '2015': 0.84; 'joel': 0.91; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=Z9GU5o5Glky236IBJoJjIJzuikTokCZ5PbgBkCmZvcw=; b=iiGIoSEShkrj+DwUcTnxh9A7lUZWVtyohZMtT3ZniLXNPjlm2LxSAuvSOiy5OPOTt6 kzfHGV63LWDs4E/bP67QTmtd/8imWm4PmOTnP1nwRE8/KY+l/7pPBhnuPBYAKJLHvTHc zqLbfFZnSNBgG1IYsGH7e45FLfa5L01IqK8Is8wuLXGAGDoFZt87Gq0TKffYw0O3XHDi 0LMJZAAxAC7khBRq4x2W0Yt1CdDjAjBwcbXp5TO/ff7pJ4VdUfkQx7+Sn6Ibivm1oHz+ 5WDlyRma8ZTw+SV9WoEX+Pl8ggKCDHFcUTDLFpOQ3ViU/vDJXuRG53W2l081kZM3UezZ NiGQ==
MIME-Version 1.0
X-Received by 10.42.37.144 with SMTP id y16mr71425820icd.51.1426444291273; Sun, 15 Mar 2015 11:31:31 -0700 (PDT)
In-Reply-To <8412cc81-fbd2-4590-9db3-12c65ba2ee35@googlegroups.com>
References <8412cc81-fbd2-4590-9db3-12c65ba2ee35@googlegroups.com>
Date Sun, 15 Mar 2015 14:31:31 -0400
Subject Re: More or less code in python?
From Joel Goldstick <joel.goldstick@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
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.399.1426444300.21433.python-list@python.org> (permalink)
Lines 44
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1426444300 news.xs4all.nl 2839 [2001:888:2000:d::a6]:53469
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:87482

Show key headers only | View raw


On Sun, Mar 15, 2015 at 2:07 PM,  <jonas.thornvall@gmail.com> wrote:
> <SCRIPT LANGUAGE="Javascript">
>
> function naiveAdd(base,arrOne,arrTwo) {
> if (arrOne.length>=arrTwo.length) {length=arrOne.length;} else {length=arrTwo.length;}
> out="";
> remainder=0;
> for (i=0;i<length;i++){
> one=arrOne[i];
> two=arrTwo[i];
> one=parseInt(one);
> two=parseInt(two);
> if (isNaN(one)) one = 0;
> if (isNaN(two)) two = 0;
> sum=one+two+remainder;
>
> if (sum>=base) { sum=sum-base; remainder=1;} else {remainder=0;}
> out=","+sum+out;
> }
> if (remainder==1) out=remainder+out;
> return out;
> }
> base=16;
> strOne="2,2";
> strTwo="13,13";
> arrOne=strOne.split(",");
> arrTwo=strTwo.split(",");
> arrOne.reverse();
> arrTwo.reverse();
> naiveAdd(base,arrOne,arrTwo);
> document.write("Sum = ",out,"<BR>");
> </SCRIPT>
> --
> https://mail.python.org/mailman/listinfo/python-list

I'm guessing less, if your question is whether this code would be
fewer lines in python.  However, it would be nice if you formatted it
so that it is readable, and gave a description of what you think the
code is doing, or should be doing.  Its an odd question in that python
generally runs on a server and javascript in a browser

-- 
Joel Goldstick
http://joelgoldstick.com

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


Thread

More or less code in python? jonas.thornvall@gmail.com - 2015-03-15 11:07 -0700
  Re: More or less code in python? Joel Goldstick <joel.goldstick@gmail.com> - 2015-03-15 14:31 -0400
    Re: More or less code in python? jonas.thornvall@gmail.com - 2015-03-15 11:56 -0700
    Re: More or less code in python? jonas.thornvall@gmail.com - 2015-03-15 12:00 -0700
      Re: More or less code in python? Paul Rubin <no.email@nospam.invalid> - 2015-03-15 12:01 -0700
        Re: More or less code in python? jonas.thornvall@gmail.com - 2015-03-15 12:03 -0700
        Re: More or less code in python? jonas.thornvall@gmail.com - 2015-03-15 12:09 -0700
          Re: More or less code in python? Dave Angel <davea@davea.name> - 2015-03-16 03:32 -0400
          Re: More or less code in python? Chris Angelico <rosuav@gmail.com> - 2015-03-16 18:36 +1100
          Re: More or less code in python? Dave Angel <davea@davea.name> - 2015-03-16 03:44 -0400
  Re: More or less code in python? Peter Otten <__peter__@web.de> - 2015-03-15 20:15 +0100

csiph-web