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

View of /tests/trunk/bugs/tests.obsolete/bug1156.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: 884 byte(s)
(* bug1156.sml *)

structure I :
  sig
    type 'a intmap
    val new : unit -> bool intmap
    val add : '2a intmap -> int * '2a -> unit
    val map : 'a intmap -> int -> 'a
  end =
struct
  open Array List
  infix 9 sub
  datatype 'a bucket = NIL | B of (int * 'a * 'a bucket)
  datatype 'a intmap =
    H of {table: 'a bucket array ref,exn: exn}
  val new = fn () => H{table=ref(array(16,NIL)),exn=Overflow}
  fun index () = 
    let val k = 16 (* Array.length a *)
	val v = Word.fromInt(k - 1)
	val w = Word.andb(0wx2, v) 
	val z = Word.toInt w
     in z
    end
  fun map (H{table,exn}) =
      (fn i => let val ref a = table
		   val nn = index () 
		   val _ = print ((Int.toString nn) ^ " nnn \n")
		   fun find NIL = raise exn
		     | find(B(i',j,r)) = if i=i' then j else find r
	       in find(a sub nn) 
	       end)

  fun add _ _ = ()
end;

val x = I.map (I.new())  2;

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