about summary refs log blame commit diff stats
path: root/033length.cc
blob: 126a14e7660779cec3ec93a09c081b6a98ce420d (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13

                                             
                        









                                     

                                             

                                        

                                                
                                                             



                                                                                
                               
                                                  
                                    
                                                          

        
//: Recipe to compute the length of an array.

:(scenario array_length)
recipe main [
  1:integer <- copy 3:literal
  2:integer <- copy 14:literal
  3:integer <- copy 15:literal
  4:integer <- copy 16:literal
  5:integer <- length 1:array:integer
]
+run: instruction main/4
+mem: storing 3 in location 5

:(before "End Primitive Recipe Declarations")
LENGTH,
:(before "End Primitive Recipe Numbers")
Recipe_number["length"] = LENGTH;
:(before "End Primitive Recipe Implementations")
case LENGTH: {
  reagent x = canonize(current_instruction().ingredients[0]);
  if (x.types[0] != Type_number["array"]) {
    raise << "tried to calculate length of non-array " << x.to_string() << '\n';
    break;
  }
  vector<long long int> result;
//?   cout << "length: " << x.value << '\n'; //? 1
  result.push_back(Memory[x.value]);
  write_memory(current_instruction().products[0], result);
  break;
}
896449a0d61c395b714bab59c5f0'>986eebff ^
5e938dc1 ^
7284d503 ^
88be3dbc ^
5e938dc1 ^





6f5d7864 ^
5e938dc1 ^

57699011 ^
5e938dc1 ^
88be3dbc ^
b9011f34 ^








57699011 ^
b9011f34 ^
f1a3be1c ^

5e938dc1 ^
88be3dbc ^
db5c9550 ^
5e938dc1 ^





6f5d7864 ^
5e938dc1 ^


f1a3be1c ^

c51043ab ^




a66c9ae6 ^
c51043ab ^





a66c9ae6 ^
c51043ab ^




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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130