|
32 | 32 | [index item] > withi |
33 | 33 | concat. > @ |
34 | 34 | with. |
35 | | - head index |
| 35 | + front index |
36 | 36 | item |
37 | | - tail |
| 37 | + back |
38 | 38 | origin.length.minus index |
39 | 39 |
|
40 | 40 | # Reduce with index from "start" using the function "func". |
|
52 | 52 | tup.length.eq 1 |
53 | 53 | func |
54 | 54 | start |
55 | | - tup.value |
| 55 | + tup.head |
56 | 56 | 0 |
57 | 57 | func |
58 | | - rec-reducedi tup.prev |
59 | | - tup.value |
60 | | - tup.prev.length |
| 58 | + rec-reducedi tup.tail |
| 59 | + tup.head |
| 60 | + tup.tail.length |
61 | 61 |
|
62 | 62 | # Reduce from "start" using the function "func". |
63 | 63 | # Here "func" must be an abstract object with two free attributes. |
|
143 | 143 | first.length.eq 0 |
144 | 144 | true |
145 | 145 | and. |
146 | | - first.value.eq second.value |
147 | | - rec-eq first.prev second.prev |
| 146 | + first.head.eq second.head |
| 147 | + rec-eq first.tail second.tail |
148 | 148 |
|
149 | 149 | # Concatenates current list with given one. |
150 | 150 | [passed] > concat |
|
165 | 165 | if. |
166 | 166 | next.eq -1 |
167 | 167 | if. |
168 | | - tup.value.eq wanted |
169 | | - tup.prev.length |
| 168 | + tup.head.eq wanted |
| 169 | + tup.tail.length |
170 | 170 | -1 |
171 | 171 | next |
172 | | - rec-index-of tup.prev > next! |
| 172 | + rec-index-of tup.tail > next! |
173 | 173 |
|
174 | 174 | # Returns index of the last particular item in list. |
175 | 175 | # If the list has no this item, returns -1. |
|
181 | 181 | tup.length.eq 0 |
182 | 182 | -1 |
183 | 183 | if. |
184 | | - tup.value.eq wanted |
185 | | - tup.prev.length |
186 | | - rec-last-index-of tup.prev |
| 184 | + tup.head.eq wanted |
| 185 | + tup.tail.length |
| 186 | + rec-last-index-of tup.tail |
187 | 187 |
|
188 | 188 | # Returns `true` if the list contains `element`. |
189 | 189 | # Otherwise, `false`. |
|
208 | 208 | tup.length.eq 0 |
209 | 209 | * |
210 | 210 | if. |
211 | | - func tup.value tup.prev.length |
212 | | - next.with tup.value |
| 211 | + func tup.head tup.tail.length |
| 212 | + next.with tup.head |
213 | 213 | next |
214 | | - rec-filteredi tup.prev > next |
| 214 | + rec-filteredi tup.tail > next |
215 | 215 |
|
216 | 216 | # Filter list without index with the function `func`. |
217 | 217 | # Here `func` must be an abstract object |
|
223 | 223 | func item > [item index] >> |
224 | 224 |
|
225 | 225 | # Get the first `index` elements from the start of the list. |
226 | | - [index] > head |
| 226 | + [index] > front |
227 | 227 | if. > @ |
228 | 228 | idx.eq 0 |
229 | 229 | list * |
230 | 230 | if. |
231 | 231 | 0.gt idx |
232 | | - tail (number idx).neg |
| 232 | + back (number idx).neg |
233 | 233 | if. |
234 | 234 | (number idx).gte origin.length |
235 | 235 | ^ |
|
241 | 241 | if. > @ |
242 | 242 | tup.length.eq idx |
243 | 243 | tup |
244 | | - rec-head tup.prev |
| 244 | + rec-head tup.tail |
245 | 245 |
|
246 | 246 | # Get the last `index` elements from the end of the list. |
247 | | - [index] > tail |
| 247 | + [index] > back |
248 | 248 | if. > @ |
249 | 249 | 0.gt start |
250 | 250 | ^ |
|
688 | 688 | * false |
689 | 689 |
|
690 | 690 | # This unit test is supposed to check the functionality of the corresponding object. |
691 | | - [] +> tests-simple-head |
| 691 | + [] +> tests-simple-front |
692 | 692 | eq. > @ |
693 | | - head. |
| 693 | + front. |
694 | 694 | list |
695 | 695 | * 1 2 3 4 5 |
696 | 696 | 1 |
697 | 697 | * 1 |
698 | 698 |
|
699 | 699 | # This unit test is supposed to check the functionality of the corresponding object. |
700 | | - [] +> tests-list-head-with-zero-index |
| 700 | + [] +> tests-list-front-with-zero-index |
701 | 701 | is-empty. > @ |
702 | | - head. |
| 702 | + front. |
703 | 703 | list |
704 | 704 | * 1 2 3 |
705 | 705 | 0 |
706 | 706 |
|
707 | 707 | # This unit test is supposed to check the functionality of the corresponding object. |
708 | | - [] +> tests-list-head-with-length-index |
| 708 | + [] +> tests-list-front-with-length-index |
709 | 709 | eq. > @ |
710 | | - head. |
| 710 | + front. |
711 | 711 | list |
712 | 712 | * 1 2 3 |
713 | 713 | 3 |
714 | 714 | * 1 2 3 |
715 | 715 |
|
716 | 716 | # This unit test is supposed to check the functionality of the corresponding object. |
717 | | - [] +> tests-complex-head |
| 717 | + [] +> tests-complex-front |
718 | 718 | eq. > @ |
719 | | - head. |
| 719 | + front. |
720 | 720 | list |
721 | 721 | * "foo" 2.2 00-01 "bar" |
722 | 722 | 2 |
723 | 723 | * "foo" 2.2 |
724 | 724 |
|
725 | 725 | # This unit test is supposed to check the functionality of the corresponding object. |
726 | | - [] +> tests-head-with-negative |
| 726 | + [] +> tests-front-with-negative |
727 | 727 | eq. > @ |
728 | | - head. |
| 728 | + front. |
729 | 729 | list |
730 | 730 | * 1 2 3 |
731 | 731 | -1 |
732 | 732 | * 3 |
733 | 733 |
|
734 | 734 | # This unit test is supposed to check the functionality of the corresponding object. |
735 | | - [] +> tests-complex-head-with-negative |
| 735 | + [] +> tests-complex-front-with-negative |
736 | 736 | eq. > @ |
737 | | - head. |
| 737 | + front. |
738 | 738 | list |
739 | 739 | * "foo" 2.2 00-01 "bar" |
740 | 740 | -3 |
741 | 741 | * 2.2 00-01 "bar" |
742 | 742 |
|
743 | 743 | # This unit test is supposed to check the functionality of the corresponding object. |
744 | | - [] +> tests-simple-tail |
| 744 | + [] +> tests-simple-back |
745 | 745 | eq. > @ |
746 | | - tail. |
| 746 | + back. |
747 | 747 | list |
748 | 748 | * 1 2 3 4 5 |
749 | 749 | 2 |
750 | 750 | * 4 5 |
751 | 751 |
|
752 | 752 | # This unit test is supposed to check the functionality of the corresponding object. |
753 | | - [] +> tests-zero-index-in-tail |
| 753 | + [] +> tests-zero-index-in-back |
754 | 754 | is-empty. > @ |
755 | | - tail. |
| 755 | + back. |
756 | 756 | list |
757 | 757 | * 1 2 3 4 5 |
758 | 758 | 0 |
759 | 759 |
|
760 | 760 | # This unit test is supposed to check the functionality of the corresponding object. |
761 | | - [] +> tests-large-index-in-tail |
| 761 | + [] +> tests-large-index-in-back |
762 | 762 | eq. > @ |
763 | | - tail. |
| 763 | + back. |
764 | 764 | list |
765 | 765 | * 1 2 3 4 5 |
766 | 766 | 10 |
|
0 commit comments