about summary refs log tree commit diff stats
path: root/126write-int-decimal.subx
Commit message (Expand)AuthorAgeFilesLines
* print call stack on all low-level errorsKartik K. Agaram2021-05-151-8/+2
* undo previous commitKartik K. Agaram2021-04-051-7/+0
* snapshot: stupid debugging sessionKartik K. Agaram2021-04-051-0/+7
* 7866Kartik Agaram2021-03-071-20/+20
* 7842 - new directory organizationKartik K. Agaram2021-03-031-46/+8
* 6821 - highlight words clobbered by the next wordKartik Agaram2020-09-201-2/+2
* 6808Kartik Agaram2020-09-191-1/+1
* 6627Kartik Agaram2020-07-101-1/+1
* 6612 - reorganize layersKartik Agaram2020-07-051-0/+466
gt; 2015-07-28 14:33:22 -0700 1868 - start using naked literals everywhere' href='/akkartik/mu/commit/062array.mu?h=main&id=bc6436927640603675e2e700007f53c5ab213869'>bc643692 ^
9636c7ae ^

d4cb1a51 ^
502d2ea5 ^

9636c7ae ^

455fbac6 ^
9636c7ae ^
bc643692 ^
9636c7ae ^

502d2ea5 ^

d4cb1a51 ^
502d2ea5 ^
d4cb1a51 ^
502d2ea5 ^

9636c7ae ^

502d2ea5 ^
9636c7ae ^
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

                          

                                                               
   
                         







                                              
                                                           
             
                           

                           
                                                            

                               

        
                                        
                    
                    

                           

                                                 
                                                            
                                                                 
                                                     

                           

        
              
 
scenario array-from-args [
  run [
    1:address:shared:array:character <- new-array 0, 1, 2
    2:array:character <- copy *1:address:shared:array:character
  ]
  memory-should-contain [
    2 <- 3  # array length
    3 <- 0
    4 <- 1
    5 <- 2
  ]
]

# create an array out of a list of scalar args
recipe new-array -> result:address:shared:array:character [
  local-scope
  capacity:number <- copy 0
  {
    # while read curr-value
    curr-value:character, exists?:boolean <- next-ingredient
    break-unless exists?
    capacity <- add capacity, 1
    loop
  }
  result <- new character:type, capacity
  rewind-ingredients
  i:number <- copy 0
  {
    # while read curr-value
    done?:boolean <- greater-or-equal i, capacity
    break-if done?
    curr-value:character, exists?:boolean <- next-ingredient
    assert exists?, [error in rewinding ingredients to new-array]
    tmp:address:character <- index-address *result, i
    *tmp <- copy curr-value
    i <- add i, 1
    loop
  }
  reply result
]