🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.lang.ml
Article #3

can this be implemented in O(1) space?

#3
From: Jacob Gore
Date: Mon, 06 Apr 1992 02:51
15 lines
815 bytes
Consider the following function for computing x to the power of n:

fun power(x,n) =
  if n=0 then 1.0
  else if n mod 2 = 1 then x * power(x,n-1)
  else power(x*x, n div 2);

What is the likelihood of an SML implementation doing it in O(1) space?

Jacob
--
Jacob Gore			Mathematical and Computer Sciences
<JGore@Mines.Colorado.Edu>	Colorado School of Mines

	-- Member of the League for Programming Freedom --
Technical Details
Message-ID: <1992Apr06.025126.33552@slate.mines.colorado.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!csn!copper!slate!

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!csn!copper!slate!
From: jgore@Mines.Colorado.Edu (Jacob Gore)
Newsgroups: alt.lang.ml
Subject: can this be implemented in O(1) space?
Message-ID: <1992Apr06.025126.33552@slate.mines.colorado.edu>
Date: 6 Apr 92 02:51:26 GMT
Sender: @slate.mines.colorado.edu
Organization: Colorado School of Mines
Lines: 15