🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by S.R.L.Meira Tue, 16 Aug 1983 09:48
recursion -- from net.lang
#35
Author: S.R.L.Meira
Date: Tue, 16 Aug 1983 09:48
54 lines
2491 bytes
	The article below was posted by Joe Fasel in net.lang, last April.
	I'm posting it again (hope Joe doesn't mind) to net.applic, both
	to test our (uk+europe) net.applic connection and to tell "applic"
	subscribers what was happening elsewhere (a long time ago). It
	also serves as an invitation to all of you to POST NEWS TO NET.APPLIC
	(We haven't seen anything there for ages !!...)

	silvio lemos meira --- srlm@ukc


--------------------------------------------------------------------------------
From lime!houxg!hogpc!houxm!npoiv!npois!hou5f!ariel!vax135!floyd!cmcl2!lanl-a!jhf Wed Apr 20 14:30:17 1983
Full-Name: 
Newsgroups: net.lang
Subject: Re: {Re:}* Recursion
Article-ID: net.lang/75
--------------------------------------------------------------------------------

Yes indeed, probably the most natural way to define the factorial function
is as the product of the integers 1 through n.  I think one sees the
the version

	fact(n) = if n=0 then 1 else n*fact(n-1)

so often not because it is the best way to define factorial, but because
it is one of the simplest functions by which to demonstrate recursion.

Take a look David Turner's (U. of Kent at Canterbury) language KRC.
In it, one can write (I may not have the syntax exactly right.)

	fact n = product [1..n]

after defining

	product L = reduce times 1 L

where

	reduce f ident nil = ident
	reduce f ident x:L = f x (reduce f ident L)

The ":" denotes the pairing operation, like Lisp cons.  The  ".." notation
is a shorthand for constructing lists (possibly infinite) of consecutive
integers.  Turner says it has proved useful for eliminating the sort
of "junk recursion" we see in the first implementation of fact, above.

I have probably mucked up this example, although I think I have the spirit
of it right.  Any comments from folks at ukc?

Joe Fasel
Los Alamos National Laboratory
{ucbvax!lbl-csam | pur-ee!purdue | harpo!floyd!cmcl2}!lanl-a!jhf
JFasel@LANL
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads