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/bug577.sml
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2460 - (download) (annotate)
Sat Apr 28 20:18:10 2007 UTC (12 years, 1 month ago) by gkuan
File size: 681 byte(s)
(* bug577.sml *)
(* 577. use of vectors crashes NeXT *)

open Vector;

fun update(array,index,value) = 
    let
	fun copy i = 

	    if i = index then value
	    else sub(array,i)
	val size = length array
    in
	if index < size then
	    tabulate (size,copy)
	else
	    raise Subscript
    end;

fun reverse original =
    let
	val size = length original
	fun rev (current,count) =
	    if count < size then
		let
		    val count'  = count + 1
		    val current' =
			update(current, count, sub(original, size-count'))
		in
		    rev (current', count')
		end
	    else current
    in
	rev (original,0)
    end;

fun bug n = reverse (tabulate (n, fn x => x));

bug 500;

bug 1000;

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