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

📄 io-util.sml

📁 这是我们参加06年全国开源软件的竞赛作品
💻 SML
字号:
(* io-util.sml * * COPYRIGHT (c) 1997 AT&T Labs Research. *)structure IOUtil : IO_UTIL =  struct    type instream = TextIO.instream    type outstream = TextIO.outstream    fun swapInstrm (s, s') =	  TextIO.getInstream s before TextIO.setInstream(s, s')    fun withInputFile (s, f) x = let	  val oldStrm = swapInstrm(TextIO.stdIn, TextIO.getInstream(TextIO.openIn s))	  fun cleanUp () =		TextIO.StreamIO.closeIn(swapInstrm(TextIO.stdIn, oldStrm))	  val res = (f x) handle ex => (cleanUp(); raise ex)	  in	    cleanUp();	    res	  end    fun withInstream (strm, f) x = let	    val oldStrm = swapInstrm(TextIO.stdIn, TextIO.getInstream strm)	    fun cleanUp () =		  TextIO.setInstream(strm, swapInstrm(TextIO.stdIn, oldStrm))	    val res = (f x) handle ex => (cleanUp(); raise ex)	    in	      cleanUp();	      res	    end    fun swapOutstrm (s, s') =	  TextIO.getOutstream s before TextIO.setOutstream(s, s')    fun withOutputFile (s, f) x = let	  val oldStrm = swapOutstrm(TextIO.stdOut, TextIO.getOutstream(TextIO.openOut s))	  fun cleanUp () =		TextIO.StreamIO.closeOut(swapOutstrm(TextIO.stdOut, oldStrm))	  val res = (f x) handle ex => (cleanUp(); raise ex)	  in	    cleanUp();	    res	  end    fun withOutstream (strm, f) x = let	    val oldStrm = swapOutstrm(TextIO.stdOut, TextIO.getOutstream strm)	    fun cleanUp () =		  TextIO.setOutstream(strm, swapOutstrm(TextIO.stdOut, oldStrm))	    val res = (f x) handle ex => (cleanUp(); raise ex)	    in	      cleanUp();	      res	    end  end (* IOUtil *)

⌨️ 快捷键说明

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