Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /tests/trunk/bugs/tests.obsolete/bug874.sml
ViewVC logotype

View of /tests/trunk/bugs/tests.obsolete/bug874.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2460 - (download) (annotate)
Sat Apr 28 20:18:10 2007 UTC (12 years, 2 months ago) by gkuan
File size: 446 byte(s)
(* bug874.sml *)

val (f,prev) =
    let exception notFound
	fun lookup(a,[]) = raise notFound
	  | lookup (a, (b,ans)::rest) = if a=b then ans else lookup(a,rest)
	val prev = ref []
	fun g  0 = 1
	  | g ~1 = 0
	  | g ~2 = 0
	  | g  n = (lookup(n,!prev)
		      handle notFound =>
			let val soln = g(n-3)+g(n-2)+g(n-1)
			in  prev := (n,soln) :: !prev;
			    soln
			end)
     in (g, prev)
    end;

f 35 handle Overflow => 0;
length(!prev);



root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0