From c842d90bbc5ab8f4fb88fb89ebb02c0c12051396 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 27 Jul 2016 22:51:11 -0700 Subject: 3158 --- html/067stream.mu.html | 75 -------------------------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 html/067stream.mu.html (limited to 'html/067stream.mu.html') diff --git a/html/067stream.mu.html b/html/067stream.mu.html deleted file mode 100644 index 6bafe8b4..00000000 --- a/html/067stream.mu.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - -Mu - 067stream.mu - - - - - - - - - - -
-# new type to help incrementally read texts (arrays of characters)
-container stream [
-  index:number
-  data:address:array:character
-]
-
-def new-stream s:address:array:character -> result:address:stream [
-  local-scope
-  load-ingredients
-  result <- new stream:type
-  *result <- put *result, index:offset, 0
-  *result <- put *result, data:offset, s
-]
-
-def rewind-stream in:address:stream -> in:address:stream [
-  local-scope
-  load-ingredients
-  *in <- put *in, index:offset, 0
-]
-
-def read-line in:address:stream -> result:address:array:character, in:address:stream [
-  local-scope
-  load-ingredients
-  idx:number <- get *in, index:offset
-  s:address:array:character <- get *in, data:offset
-  next-idx:number <- find-next s, 10/newline, idx
-  result <- copy-range s, idx, next-idx
-  idx <- add next-idx, 1  # skip newline
-  # write back
-  *in <- put *in, index:offset, idx
-]
-
-def end-of-stream? in:address:stream -> result:boolean [
-  local-scope
-  load-ingredients
-  idx:number <- get *in, index:offset
-  s:address:array:character <- get *in, data:offset
-  len:number <- length *s
-  result <- greater-or-equal idx, len
-]
-
- - - -- cgit 1.4.1-2-gfad0