🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.folklore.computers
Article #623806

Re: The dictionary definition of recursion

#623806
From: Questor
Date: Wed, 06 Jun 2018 06:25
46 lines
3217 bytes
On Tue, 5 Jun 2018 15:42:33 +0100, Gareth's Downstairs Computer
<headstone255.but.n...@yahoo.com> wrote:
>On 05/06/2018 15:28, Andrew Swallow wrote:
>> On 04/06/2018 17:16, Gareth's Downstairs Computer wrote:
>>> Recursion : see  recursion.
>>>
>>> As a recursive "elegant" solution,
>>>
>>> factorial (1,000,000) is likely to
>>> crash most systems
>> 
>> Factorial is a simple loop.
>> 
>
>The discussion was not about iteration but the
>claimed elegance of recursion.
>
>However, another iterative process where recursion is
>unnecessary is the walking of trees; certainly a B Tree
>where all are sorted, for you take the standard approach
>of walking a maze (a maze with no internal doors!!!!!) of
>always taking the leftmost branch, by always first going
>for the lowest branch

Below a simple version of the "standard" DEC routine for number output -- using
the stack to reverse the order of digits.  Recursion is also very useful for
generating permutations and combinations.


[best viewed with fixed-width typeface]


;Recursive decimal output routine -- number in T1
;
; Since a PDP10 address fits in the right half of a word, the left half
; can be used to hold each digit.  On other machines, it would be PUSHed
; onto the stack and subsequently POPed off.

DECOUT: IDIVI T1, 10.                   ;remainder in T2
        HRLM  T2, (P)                   ;save stack space -- use left half
        SKIPE T1                        ;anything left?
         PUSHJ P, DECOUT                ;yes, call DECOUT recursively
        HLRZ  T2, (P)                   ;retrieve stashed digit
        ADDI  T2, "0"                   ;convert to ASCII
        OUTCHR  T2                      ;
        POPJ  P,                        ;
Technical Details
Message-ID: <5b177aa2.1598318@news.dslextreme.com>
Path: mbox-mo1.pugleaf.net!n13-v6ni9196wmc.0!nntp.google.com!goblin3!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!85.12.16.70.MISMATCH!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.am4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!post01.iad!fx34.iad.POSTED!not-for-mail
References: <pf3oke$hq8$1@dont-email.me> <L9Sdnc69nM-WA4vGnZ2dnUU78RvNnZ2d@giganews.com> <pf67gs$fpm$1@dont-email.me>

Show Full Headers
Complete Article Headers
X-Received: by 2002:adf:ea0e:: with SMTP id q14-v6mr113564wrm.15.1528266393014;        Tue, 05 Jun 2018 23:26:33 -0700 (PDT)
X-BeenThere: alt.folklore.computers@googlegroups.com
Received: by 2002:adf:dd88:: with SMTP id x8-v6ls7379348wrl.9.gmail; Tue, 05 Jun 2018 23:26:32 -0700 (PDT)
X-Received: by 2002:adf:f011:: with SMTP id j17-v6mr117963wro.31.1528266392275;        Tue, 05 Jun 2018 23:26:32 -0700 (PDT)
MIME-Version: 1.0
Path: mbox-mo1.pugleaf.net!n13-v6ni9196wmc.0!nntp.google.com!goblin3!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!85.12.16.70.MISMATCH!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.am4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!post01.iad!fx34.iad.POSTED!not-for-mail
From: usenet@only.tnx (Questor)
Newsgroups: alt.folklore.computers
Subject: Re: The dictionary definition of recursion
Organization: random access
Reply-To: usenet@only.tnx
Message-ID: <5b177aa2.1598318@news.dslextreme.com>
References: <pf3oke$hq8$1@dont-email.me> <L9Sdnc69nM-WA4vGnZ2dnUU78RvNnZ2d@giganews.com> <pf67gs$fpm$1@dont-email.me>
X-Newsreader: Forte Free Agent 1.21/32.243
Lines: 47
X-Complaints-To: abu...@dslextreme.com
NNTP-Posting-Date: Wed, 06 Jun 2018 06:26:29 UTC
Date: Wed, 06 Jun 2018 06:25:37 GMT
X-Received-Bytes: 2515
X-Received-Body-CRC: 374199977
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit