Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'compiler': 0.07; 'badly': 0.09; 'wrong,': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; '"""return': 0.16; 'angle': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'opposite': 0.16; 'subject:programming': 0.16; 'do,': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'seems': 0.21; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'that.': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'skip:m 30': 0.32; 'entirely': 0.33; 'not.': 0.33; "i'd": 0.34; 'but': 0.35; 'received:google.com': 0.35; 'pm,': 0.38; 'itself': 0.39; 'sure': 0.39; 'either': 0.39; 'even': 0.60; "you're": 0.61; 'taking': 0.65; 'mar': 0.68; 'rubbish': 0.84; 'trig': 0.84; 'ratio': 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:content-transfer-encoding; bh=aavWgiOzxUir2rzZTBl9RBA7HZMhicNkemjgYXDEhVQ=; b=gGE3AGfVJtaQ8SdHky0VI5AdW8oU1ghkkFviLClsunXZFwRKlipdhdbnWqDcOAEWqP C4v6t76WFTCEPlV+I9Bvpkj6nx5PDJpHE5k3Ihfu5H9BPadQEkjfe8M7AEH1l/wjcbwq rc5QD+CVXfTfIAZPsxW4B27GStTDaVNnh6pQzPn2bVsz5klmgm9E+j9xzX4jYlBWnQZL PIJ7F+xWj8bSYkGKMjuYjbUQxw0fVBR1AHnLuJckaR2jkfxCn9KLDkKsNSnmeT+RAKRE Z1kQAWy3koQXAaVz/TnrgI4AviBnKrfiJn9VFtaO0Dyp8221wveQ88r89AMzfkyreGen IwSA== MIME-Version: 1.0 X-Received: by 10.66.181.70 with SMTP id du6mr5780570pac.23.1393938061688; Tue, 04 Mar 2014 05:01:01 -0800 (PST) In-Reply-To: <5315bd68$0$29985$c3e8da3$5496439d@news.astraweb.com> References: <4c7dbc57-eef9-4582-aecd-aac13a39b45f@googlegroups.com> <3b54a279-03a1-4a81-a428-ecad6eb16036@googlegroups.com> <216bb5f4-32c4-4f86-a9f4-1b0dd37a2a81@googlegroups.com> <0129a5b9-b85f-4ad5-b5e2-bfb2a48041d5@googlegroups.com> <5314bb96$0$29985$c3e8da3$5496439d@news.astraweb.com> <5315661c$0$2923$c3e8da3$76491128@news.astraweb.com> <53159540$0$2923$c3e8da3$76491128@news.astraweb.com> <5315bd68$0$29985$c3e8da3$5496439d@news.astraweb.com> Date: Wed, 5 Mar 2014 00:01:01 +1100 Subject: Re: Functional programming From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393938071 news.xs4all.nl 2871 [2001:888:2000:d::a6]:39221 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67670 On Tue, Mar 4, 2014 at 10:47 PM, Steven D'Aprano wrote: > Not even close. I'd like to see the compiler that can work out for itself > that this function is buggy: > > def sine_rule(side_a, side_b, angle_a): > """Return the angle opposite side_b.""" > return math.sin(side_b/side_a)*angle_a > > > If you don't remember your Sine Rule from trigonometry, that's okay. > Trust me, the function is badly wrong. It's rubbish really. I'm not entirely sure what it's trying to do, but you're taking the sine of a ratio. That... seems wrong, gut-feeling-wise. You take the sine of an angle and get a ratio, or the arcsine of a ratio and get an angle. Also, trig functions apply only to right triangles, so the other angle is either going to be 90=C2=B0-angle_a or 90=C2=B0, depending o= n whether you want the angle opposite the hypotenuse or not. But it's years since I studied any of that. ChrisA