⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 time-limit.sml

📁 这是我们参加06年全国开源软件的竞赛作品
💻 SML
字号:
(* time-limit.sml * * COPYRIGHT (c) 1993 by AT&T Bell Laboratories.  See COPYRIGHT file for details. *)structure TimeLimit : sig    exception TimeOut    val timeLimit : Time.time -> ('a -> 'b) -> 'a -> 'b  end = struct    exception TimeOut    fun timeLimit t f x = let	  val setitimer = SMLofNJ.IntervalTimer.setIntTimer	  fun timerOn () = ignore(setitimer (SOME t))	  fun timerOff () = ignore(setitimer NONE)	  val escapeCont = SMLofNJ.Cont.callcc (fn k => (		SMLofNJ.Cont.callcc (fn k' => (SMLofNJ.Cont.throw k k'));		timerOff();		raise TimeOut))	  fun handler _ = escapeCont	  in	    Signals.setHandler (Signals.sigALRM, Signals.HANDLER handler);	    timerOn();	    ((f x) handle ex => (timerOff(); raise ex))	      before timerOff()	  end  end; (* TimeLimit *)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -