🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: sci.logic
Article #761

Re: The only decent mathematicians here are accomplished PROGRAMMERS

#761
From: Owen Jacobson
Date: Wed, 21 Sep 2011 04:26
63 lines
3959 bytes
On 2011-09-20 12:05:37 +0000, David C. Ullrich said:

> On Tue, 20 Sep 2011 03:35:39 -0700 (PDT), scaaahu <scaaahu@gmail.com>
> wrote:
> 
>> I fail to see how to store an irrational number like Pi.
> 
> What's the difference?  You store code that calculates
> the first n digits on request...
> 
> Heh. As it happens I just got this book on Haskell. I haven't
> been able to install Haskell, however, so I have no idea whether
> the following code is correct. But a corrected version will
> give the digits for the irrational number .10100100010000...
> (pi would be the same except the code would be much
> more complicated):
> 
> zeroes 0 = []
> zeroes j = 0 : (zeroes (j-1))
> 
> x j = [1] ++ (zeroes j) ++ (x (j+1))
> 
> So, expanding bit by bit, x  1 evaluates to
> 
> [1] ++ (zeroes 1) ++ (x 2),
> 
> or [1,0] + (x, 2).
> 
> which evvaluates to [1,0] ++ [1,0,0] ++ (x 3),
> 
> etc.

Looks pretty good to me, plus or minus the module preamble:

---- transcript begins ----
:)owen@nj1:~/dcu$ cat Dcu.hs
module Dcu where

zeroes 0 = []
zeroes j = 0 : (zeroes (j-1))

x j = [1] ++ (zeroes j) ++ (x (j+1))

:)owen@nj1:~/dcu$ ghci
GHCi, version 6.12.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.

Prelude> :add Dcu
[1 of 1] Compiling Dcu              ( Dcu.hs, interpreted )
Ok, modules loaded: Dcu.

*Dcu> take 20 $ x 1
[1,0,1,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,0]
---- transcript ends ----

(The dollar sign there is a notational convenience; that last 
expression is equivalent to 'take 20 (x 1)'.)

Take care,

-o
Technical Details
Message-ID: <2011092100263283965-angrybaldguy@gmailcom>
Path: arc1-ca.pugleaf.net!lh7ni1573pbb.0!nntp.google.com!news1.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe07.iad.POSTED!00000000!not-for-mail
References: <3e60e048-bdb9-40f9-b361-8633e0d5cdac@f17g2000yqh.googlegroups.com> <2435d6d4-a6e7-45fa-a248-11a4b15e7ffb@ge10g2000vbb.googlegroups.com> <ac0eb6ff-5b6f-4c57-aa5c-8cc6fc24f4d4@bl1g2000vbb.googlegroups.com> <j595od$da4$1@dont-email.me> <1cb81f53-cf5c-47e6-9baf-34310e36f183@n12g2000yqh.googlegroups.com> <da4dfc1a-ea1f-4e39-b468-be9ef7090cc2@n35g2000yqf.googlegroups.com> <c4858715-c638-4abf-a5ce-0e67e2a5ec1b@d41g2000yqc.googlegroups.com> <79184096-79cf-4126-83ea-cf68be15956e@k15g2000yqd.googlegroups.com> <02d4175e-1f85-48c3-9825-2af8433c9924@k15g2000yqd.googlegroups.com> <2dac6b8b-fe96-4388-947e-b9c1f22ff00d@m38g2000vbn.googlegroups.com> <5c0efb66-7ffc-412e-a4f0-fcb2f349d359@et6g2000vbb.googlegroups.com> <447a7e82-0d9c-422b-be70-47430609d3a2@8g2000yqm.googlegroups.com> <87ty87wm93.fsf@aatuk-AOA150.i-did-not-set--mail-host-address--so-tickle-me> <8da79b5f-d168-484c-a7b7-edcefd94bbf3@8g2000yqm.googlegroups.com> <8qvg77ls3bsjlkjoe0ss7rcpab5v8t0tj7@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc56,7378e085548607ba
X-Google-NewGroupId: yes
X-Google-Thread: 109d8a,7378e085548607ba
X-Google-NewGroupId: yes
X-Google-Thread: fd648,eb453206be5eeda4
X-Google-NewGroupId: yes
X-Google-Thread: 106b5d,eb453206be5eeda4
X-Google-NewGroupId: yes
X-Google-Attributes: gide4b186767d,gid9ef9b79ae9,giddb42311052,gid3b9c5691a5,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Received: by 10.68.12.68 with SMTP id w4mr284792pbb.18.1316579187897;
        Tue, 20 Sep 2011 21:26:27 -0700 (PDT)
Path: arc1-ca.pugleaf.net!lh7ni1573pbb.0!nntp.google.com!news1.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe07.iad.POSTED!00000000!not-for-mail
From: Owen Jacobson <angrybaldguy@gmail.com>
Newsgroups: sci.logic,sci.math,aus.science,rec.org.mensa
Message-ID: <2011092100263283965-angrybaldguy@gmailcom>
References: <3e60e048-bdb9-40f9-b361-8633e0d5cdac@f17g2000yqh.googlegroups.com> <2435d6d4-a6e7-45fa-a248-11a4b15e7ffb@ge10g2000vbb.googlegroups.com> <ac0eb6ff-5b6f-4c57-aa5c-8cc6fc24f4d4@bl1g2000vbb.googlegroups.com> <j595od$da4$1@dont-email.me> <1cb81f53-cf5c-47e6-9baf-34310e36f183@n12g2000yqh.googlegroups.com> <da4dfc1a-ea1f-4e39-b468-be9ef7090cc2@n35g2000yqf.googlegroups.com> <c4858715-c638-4abf-a5ce-0e67e2a5ec1b@d41g2000yqc.googlegroups.com> <79184096-79cf-4126-83ea-cf68be15956e@k15g2000yqd.googlegroups.com> <02d4175e-1f85-48c3-9825-2af8433c9924@k15g2000yqd.googlegroups.com> <2dac6b8b-fe96-4388-947e-b9c1f22ff00d@m38g2000vbn.googlegroups.com> <5c0efb66-7ffc-412e-a4f0-fcb2f349d359@et6g2000vbb.googlegroups.com> <447a7e82-0d9c-422b-be70-47430609d3a2@8g2000yqm.googlegroups.com> <87ty87wm93.fsf@aatuk-AOA150.i-did-not-set--mail-host-address--so-tickle-me> <8da79b5f-d168-484c-a7b7-edcefd94bbf3@8g2000yqm.googlegroups.com> <8qvg77ls3bsjlkjoe0ss7rcpab5v8t0tj7@4ax.com>
MIME-Version: 1.0
Subject: Re: The only decent mathematicians here are accomplished PROGRAMMERS
User-Agent: Unison/2.1.5
Lines: 64
X-Complaints-To: abuse@UsenetServer.com
NNTP-Posting-Date: Wed, 21 Sep 2011 04:26:27 UTC
Date: Wed, 21 Sep 2011 00:26:32 -0400
Content-Type: text/plain; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding: 8bit