File:  [Research Unix] / researchv10dc / cmd / sml / doc / examples / cat.sml
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:33 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Dan Cross

datatype limit = Unbounded | Limited of int

fun cat Unbounded (instream,outstream) =
    while not (end_of_stream instream) do
	  output outstream (input instream (can_input instream))
  | cat (Limited limit) (instream,outstream) =
    while not (end_of_stream instream) do
	  output outstream (input instream (min(can_input instream,limit)))
      
val ucat = cat Unbounded
val lcat = cat(Limited 1024)

fun cat1 (instream,outstream) =
    while not (end_of_stream instream) do
	  output outstream (input instream 1)

fun filecat cat = fn (fin,fout) => cat(open_in fin,open_out fout)
fun screencat cat = fn fin => cat(open_in fin,std_out)


unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.