about summary refs log tree commit diff stats
path: root/html/fork.png
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-10-22 16:33:16 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-10-22 16:33:16 -0700
commit22f4b76344b2d639cbfcaad56ed681670d436548 (patch)
tree104aac7fad7b8790995a9eff47cda53e599eb40b /html/fork.png
parentf40b079c2a7abf824e29451837f188f7cce7b943 (diff)
downloadmu-22f4b76344b2d639cbfcaad56ed681670d436548.tar.gz
3560
Diffstat (limited to 'html/fork.png')
0 files changed, 0 insertions, 0 deletions
f='/akkartik/mu/commit/076stream.mu?h=hlt&id=104854ca941be75b187ed49f94e96e06113d0fb5'>104854ca ^
502d2ea5 ^

455fbac6 ^
104854ca ^
8fb0e672 ^

455fbac6 ^
77d5b5d6 ^
104854ca ^
502d2ea5 ^

8fb0e672 ^

455fbac6 ^
77d5b5d6 ^
104854ca ^
502d2ea5 ^
455fbac6 ^
502d2ea5 ^
802283e4 ^
502d2ea5 ^
8fb0e672 ^

455fbac6 ^
77d5b5d6 ^
104854ca ^
5fdd8e96 ^
455fbac6 ^
502d2ea5 ^
104854ca ^
8fb0e672 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
                                                                  

                  
                                     

 
                                                                                    
             

                           

                                                       
                                                                              
              

 
                                                                           
             
                  

                                                   

 
                                                                                                              
             
                  
                                                     
                                                          
                                                  
                                        
                                         

 
                                                                  
             
                  
                                     
                                                          
                         
                                     
 
# new type to help incrementally read texts (arrays of characters)
container stream [
  index:number
  data:address:shared:array:character
]

recipe new-stream s:address:shared:array:character -> result:address:shared:stream [
  local-scope
  load-ingredients
  result <- new stream:type
  i:address:number <- get-address *result, index:offset
  *i <- copy 0
  d:address:address:shared:array:character <- get-address *result, data:offset
  *d <- copy s
]

recipe rewind-stream in:address:shared:stream -> in:address:shared:stream [
  local-scope
  load-ingredients
  x:address:number <- get-address *in, index:offset
  *x <- copy 0
]

recipe read-line in:address:shared:stream -> result:address:shared:array:character, in:address:shared:stream [
  local-scope
  load-ingredients
  idx:address:number <- get-address *in, index:offset
  s:address:shared: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
]

recipe end-of-stream? in:address:shared:stream -> result:boolean [
  local-scope
  load-ingredients
  idx:number <- get *in, index:offset
  s:address:shared:array:character <- get *in, data:offset
  len:number <- length *s
  result <- greater-or-equal idx, len
]