spitewaste 0.1.012 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/spitewaste/libspw/array.spw +33 -0
- data/lib/spitewaste/libspw/bits.spw +5 -1
- data/lib/spitewaste/libspw/docs.json +207 -3
- data/lib/spitewaste/libspw/math.spw +1 -2
- data/lib/spitewaste/libspw/rational.spw +5 -1
- data/lib/spitewaste/parsers/spitewaste.rb +4 -0
- data/lib/spitewaste/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cd3201a4c8647de4fb29c8529c45fb379c2633cd660a4155e28720931202f94
|
4
|
+
data.tar.gz: 3ba703110341a406d476aa8afa8d89c8a57b9d6e136f319956f28f7d311b16e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d103c80be7025cca6d784127444702460394e4d0f137f124581212b6d92523b80c7e95e15642f9c0036b26545e821dcee206686818d0728dbe57c7b57a388ef0
|
7
|
+
data.tar.gz: 39f473d86a4df1a125a6edae3ff1e29c5a069da2aa72862834097b7151bd11c4fdfe93f8119b60c7009468e4f5c2a05ef60a92d99a9b9198485f79c42411f33d
|
@@ -72,6 +72,23 @@ aryshift: dup :dig $-- ret
|
|
72
72
|
; [7 2 8 2 0] => [7 0 2 8 3]
|
73
73
|
aryunshift: swap dup times (dup $++ :roll swap) $++ ret
|
74
74
|
|
75
|
+
; inserts the element E into array A at index I, increasing its length by 1
|
76
|
+
; [A I E] => [A']
|
77
|
+
;
|
78
|
+
; [9 5 2 3 1 4] => [9 4 5 2 4]
|
79
|
+
; [1 1 0 7] => [7 1 2]
|
80
|
+
; [3 1 1 7] => [3 7 2]
|
81
|
+
; [7 5 2 1 6] => [7 6 5 3]
|
82
|
+
aryinsert: swap copy 2 swap sub $++ :bury $++ ret
|
83
|
+
|
84
|
+
; removes the element at index I in array A, decreasing its length by 1
|
85
|
+
; [A I] => [A']
|
86
|
+
;
|
87
|
+
; [6 0 9 3 1] => [6 9 2]
|
88
|
+
; [7 5 3 1 4 0] => [5 3 1 3]
|
89
|
+
; [1 3 5 7 4 3] => [1 3 5 3]
|
90
|
+
aryremove: copy 1 swap sub :roll pop $-- ret
|
91
|
+
|
75
92
|
; returns the concatenation of arrays A and B
|
76
93
|
; [A B] => [A+B]
|
77
94
|
;
|
@@ -121,6 +138,22 @@ aryat:
|
|
121
138
|
_aryat_neg: copy 1 add dup jn _aryat_oob jump aryat
|
122
139
|
_aryat_oob: push "(aryat) index out of bounds!" :die!
|
123
140
|
|
141
|
+
; swaps the elements at indices I and J in array A
|
142
|
+
; [A I J] => [A']
|
143
|
+
;
|
144
|
+
; [6 0 8 7 4 1 3] => [6 7 8 0 4]
|
145
|
+
; [4 3 2 1 4 0 2] => [2 3 4 1 4]
|
146
|
+
; [3 2 1 3 1 1] => [3 2 1 3]
|
147
|
+
aryswap: copy 1 copy 1 sub jz _aryswap_noop
|
148
|
+
^-7 ^-6
|
149
|
+
:arydup @-6 :aryat ^-8
|
150
|
+
:arydup @-7 :aryat ^-9
|
151
|
+
@-6 :aryremove
|
152
|
+
@-7 $-- :aryremove
|
153
|
+
@-6 @-9 :aryinsert
|
154
|
+
@-7 @-8 :aryinsert ret
|
155
|
+
_aryswap_noop: pop pop ret
|
156
|
+
|
124
157
|
; returns the minimum and maximum elements of array A
|
125
158
|
; [A] => [min max]
|
126
159
|
;
|
@@ -71,4 +71,8 @@ _blength_zero: ret
|
|
71
71
|
;
|
72
72
|
; [0] => [0] [1] => [1]
|
73
73
|
; [7] => [3] [8] => [1]
|
74
|
-
popcount: push
|
74
|
+
popcount: push 0
|
75
|
+
_popcount_loop:
|
76
|
+
copy 1 push 2 mod add swap push 2 div
|
77
|
+
dup jz _popcount_done swap jump _popcount_loop
|
78
|
+
_popcount_done: pop ret
|
@@ -227,6 +227,71 @@
|
|
227
227
|
]
|
228
228
|
]
|
229
229
|
},
|
230
|
+
"aryinsert": {
|
231
|
+
"full": "inserts the element E into array A at index I, increasing its length by 1\n[A I E] => [A']\n\n[9 5 2 3 1 4] => [9 4 5 2 4]\n[1 1 0 7] => [7 1 2]\n[3 1 1 7] => [3 7 2]\n[7 5 2 1 6] => [7 6 5 3]\n",
|
232
|
+
"desc": "inserts the element E into array A at index I, increasing its length by 1",
|
233
|
+
"effect": "[A I E] => [A']",
|
234
|
+
"cases": [
|
235
|
+
[
|
236
|
+
[
|
237
|
+
9,
|
238
|
+
5,
|
239
|
+
2,
|
240
|
+
3,
|
241
|
+
1,
|
242
|
+
4
|
243
|
+
],
|
244
|
+
[
|
245
|
+
9,
|
246
|
+
4,
|
247
|
+
5,
|
248
|
+
2,
|
249
|
+
4
|
250
|
+
]
|
251
|
+
],
|
252
|
+
[
|
253
|
+
[
|
254
|
+
1,
|
255
|
+
1,
|
256
|
+
0,
|
257
|
+
7
|
258
|
+
],
|
259
|
+
[
|
260
|
+
7,
|
261
|
+
1,
|
262
|
+
2
|
263
|
+
]
|
264
|
+
],
|
265
|
+
[
|
266
|
+
[
|
267
|
+
3,
|
268
|
+
1,
|
269
|
+
1,
|
270
|
+
7
|
271
|
+
],
|
272
|
+
[
|
273
|
+
3,
|
274
|
+
7,
|
275
|
+
2
|
276
|
+
]
|
277
|
+
],
|
278
|
+
[
|
279
|
+
[
|
280
|
+
7,
|
281
|
+
5,
|
282
|
+
2,
|
283
|
+
1,
|
284
|
+
6
|
285
|
+
],
|
286
|
+
[
|
287
|
+
7,
|
288
|
+
6,
|
289
|
+
5,
|
290
|
+
3
|
291
|
+
]
|
292
|
+
]
|
293
|
+
]
|
294
|
+
},
|
230
295
|
"arypop": {
|
231
296
|
"full": "removes the element at the end of the array A, decreasing its length by 1\n[A] => [A']\n\n[10 1] => [0]\n[1 2 3 4 4] => [1 2 3 3]\n[7 10 20 30 3] => [7 10 20 2]\n",
|
232
297
|
"desc": "removes the element at the end of the array A, decreasing its length by 1",
|
@@ -338,6 +403,59 @@
|
|
338
403
|
]
|
339
404
|
]
|
340
405
|
},
|
406
|
+
"aryremove": {
|
407
|
+
"full": "removes the element at index I in array A, decreasing its length by 1\n[A I] => [A']\n\n[6 0 9 3 1] => [6 9 2]\n[7 5 3 1 4 0] => [5 3 1 3]\n[1 3 5 7 4 3] => [1 3 5 3]\n",
|
408
|
+
"desc": "removes the element at index I in array A, decreasing its length by 1",
|
409
|
+
"effect": "[A I] => [A']",
|
410
|
+
"cases": [
|
411
|
+
[
|
412
|
+
[
|
413
|
+
6,
|
414
|
+
0,
|
415
|
+
9,
|
416
|
+
3,
|
417
|
+
1
|
418
|
+
],
|
419
|
+
[
|
420
|
+
6,
|
421
|
+
9,
|
422
|
+
2
|
423
|
+
]
|
424
|
+
],
|
425
|
+
[
|
426
|
+
[
|
427
|
+
7,
|
428
|
+
5,
|
429
|
+
3,
|
430
|
+
1,
|
431
|
+
4,
|
432
|
+
0
|
433
|
+
],
|
434
|
+
[
|
435
|
+
5,
|
436
|
+
3,
|
437
|
+
1,
|
438
|
+
3
|
439
|
+
]
|
440
|
+
],
|
441
|
+
[
|
442
|
+
[
|
443
|
+
1,
|
444
|
+
3,
|
445
|
+
5,
|
446
|
+
7,
|
447
|
+
4,
|
448
|
+
3
|
449
|
+
],
|
450
|
+
[
|
451
|
+
1,
|
452
|
+
3,
|
453
|
+
5,
|
454
|
+
3
|
455
|
+
]
|
456
|
+
]
|
457
|
+
]
|
458
|
+
},
|
341
459
|
"aryrep": {
|
342
460
|
"full": "returns the array A replicated N times\n[A N] => [A']\n\n[3 2 1 3 4] => [3 2 1 3 2 1 3 2 1 3 2 1 12]\n",
|
343
461
|
"desc": "returns the array A replicated N times",
|
@@ -505,6 +623,65 @@
|
|
505
623
|
]
|
506
624
|
]
|
507
625
|
},
|
626
|
+
"aryswap": {
|
627
|
+
"full": "swaps the elements at indices I and J in array A\n[A I J] => [A']\n\n[6 0 8 7 4 1 3] => [6 7 8 0 4]\n[4 3 2 1 4 0 2] => [2 3 4 1 4]\n[3 2 1 3 1 1] => [3 2 1 3]\n",
|
628
|
+
"desc": "swaps the elements at indices I and J in array A",
|
629
|
+
"effect": "[A I J] => [A']",
|
630
|
+
"cases": [
|
631
|
+
[
|
632
|
+
[
|
633
|
+
6,
|
634
|
+
0,
|
635
|
+
8,
|
636
|
+
7,
|
637
|
+
4,
|
638
|
+
1,
|
639
|
+
3
|
640
|
+
],
|
641
|
+
[
|
642
|
+
6,
|
643
|
+
7,
|
644
|
+
8,
|
645
|
+
0,
|
646
|
+
4
|
647
|
+
]
|
648
|
+
],
|
649
|
+
[
|
650
|
+
[
|
651
|
+
4,
|
652
|
+
3,
|
653
|
+
2,
|
654
|
+
1,
|
655
|
+
4,
|
656
|
+
0,
|
657
|
+
2
|
658
|
+
],
|
659
|
+
[
|
660
|
+
2,
|
661
|
+
3,
|
662
|
+
4,
|
663
|
+
1,
|
664
|
+
4
|
665
|
+
]
|
666
|
+
],
|
667
|
+
[
|
668
|
+
[
|
669
|
+
3,
|
670
|
+
2,
|
671
|
+
1,
|
672
|
+
3,
|
673
|
+
1,
|
674
|
+
1
|
675
|
+
],
|
676
|
+
[
|
677
|
+
3,
|
678
|
+
2,
|
679
|
+
1,
|
680
|
+
3
|
681
|
+
]
|
682
|
+
]
|
683
|
+
]
|
684
|
+
},
|
508
685
|
"aryunshift": {
|
509
686
|
"full": "places the element E at the beginning of the array A, increasing its length by 1\n[A E] => [A']\n\n[3 2 1 3 7] => [7 3 2 1 4]\n[4 2 0 3 9] => [9 4 2 0 4]\n[11 2 2 10] => [10 11 2 3]\n[7 2 8 2 0] => [7 0 2 8 3]\n",
|
510
687
|
"desc": "places the element E at the beginning of the array A, increasing its length by 1",
|
@@ -1907,8 +2084,8 @@
|
|
1907
2084
|
]
|
1908
2085
|
},
|
1909
2086
|
"pow": {
|
1910
|
-
"full": "returns B raised to the power E\n[B E] => [B**E]\n\n[0 0] => [1], [0 9] => [0], [9 0] => [1]\n[3 2] => [9], [2 3] => [8], [7 4] => [2401]\n[-2 3] => [-8] [-5 0] => [1] [-4 4] => [256]\n",
|
1911
|
-
"desc": "returns B raised to the power E",
|
2087
|
+
"full": "returns B raised to the power E; if E must be negative, use ratpow instead\n[B E] => [B**E]\n\n[0 0] => [1], [0 9] => [0], [9 0] => [1]\n[3 2] => [9], [2 3] => [8], [7 4] => [2401]\n[-2 3] => [-8] [-5 0] => [1] [-4 4] => [256]\n",
|
2088
|
+
"desc": "returns B raised to the power E; if E must be negative, use ratpow instead",
|
1912
2089
|
"effect": "[B E] => [B**E]",
|
1913
2090
|
"cases": [
|
1914
2091
|
[
|
@@ -2650,7 +2827,7 @@
|
|
2650
2827
|
]
|
2651
2828
|
},
|
2652
2829
|
"ratpow": {
|
2653
|
-
"full": "returns the rational R raised to the power E\n[R E] => [R']\n\n[R(4,2) 5] => [R(32,1)]\n[R(-3,7) 0] => [R(1,1)]\n[R(-3,14) 2] => [R(9,196)]\n",
|
2830
|
+
"full": "returns the rational R raised to the power E\n[R E] => [R']\n\n[R(4,2) 5] => [R(32,1)]\n[R(-3,7) 0] => [R(1,1)]\n[R(-3,14) 2] => [R(9,196)]\n[R(5,1) -1] => [R(1,5)]\n[R(2,5) -2] => [R(25,4)]\n[R(-3,14) -3] => [R(-2744,27)]\n",
|
2654
2831
|
"desc": "returns the rational R raised to the power E",
|
2655
2832
|
"effect": "[R E] => [R']",
|
2656
2833
|
"cases": [
|
@@ -2680,6 +2857,33 @@
|
|
2680
2857
|
[
|
2681
2858
|
38654706057
|
2682
2859
|
]
|
2860
|
+
],
|
2861
|
+
[
|
2862
|
+
[
|
2863
|
+
21474836483,
|
2864
|
+
-1
|
2865
|
+
],
|
2866
|
+
[
|
2867
|
+
4294967307
|
2868
|
+
]
|
2869
|
+
],
|
2870
|
+
[
|
2871
|
+
[
|
2872
|
+
8589934603,
|
2873
|
+
-2
|
2874
|
+
],
|
2875
|
+
[
|
2876
|
+
107374182409
|
2877
|
+
]
|
2878
|
+
],
|
2879
|
+
[
|
2880
|
+
[
|
2881
|
+
12884901916,
|
2882
|
+
-3
|
2883
|
+
],
|
2884
|
+
[
|
2885
|
+
11785390260278
|
2886
|
+
]
|
2683
2887
|
]
|
2684
2888
|
]
|
2685
2889
|
},
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import array ; arycat, arydup
|
2
2
|
import util ; eq, inc, range
|
3
3
|
|
4
|
-
; returns B raised to the power E
|
5
|
-
; ! TODO: support negative exponents (return Rational)
|
4
|
+
; returns B raised to the power E; if E must be negative, use ratpow instead
|
6
5
|
; [B E] => [B**E]
|
7
6
|
;
|
8
7
|
; [0 0] => [1], [0 9] => [0], [9 0] => [1]
|
@@ -169,11 +169,15 @@ ratinv:
|
|
169
169
|
; [R(4,2) 5] => [R(32,1)]
|
170
170
|
; [R(-3,7) 0] => [R(1,1)]
|
171
171
|
; [R(-3,14) 2] => [R(9,196)]
|
172
|
-
|
172
|
+
; [R(5,1) -1] => [R(1,5)]
|
173
|
+
; [R(2,5) -2] => [R(25,4)]
|
174
|
+
; [R(-3,14) -3] => [R(-2744,27)]
|
175
|
+
ratpow: dup jn _ratpow_neg
|
173
176
|
swap push 2 :divmod push 2 mul $--
|
174
177
|
swap $RAT :divmod copy 2 mul
|
175
178
|
copy 3 :pow swap copy 3 :pow
|
176
179
|
swap :to_r :ratsimp slide 2 ret
|
180
|
+
_ratpow_neg: push -1 mul swap :ratinv swap :ratpow ret
|
177
181
|
|
178
182
|
; converts the rational number R to a "pseudo-float" with a whole (W) part
|
179
183
|
; and a fractional (F) part composed of P digits after the decimal point
|
@@ -117,6 +117,10 @@ module Spitewaste
|
|
117
117
|
@src.gsub!(/'(.)'/) { $1.ord }
|
118
118
|
# quick push (`push 1,2,3` desugars to individual pushes)
|
119
119
|
@src.gsub!(/push \S+/) { |m| m.split(?,) * ' push ' }
|
120
|
+
# quick store (`^2` = `push 2 swap store`)
|
121
|
+
@src.gsub!(/\^(-?\d+)/, 'push \1 swap store')
|
122
|
+
# quick load (`@2` = `push 2 load`)
|
123
|
+
@src.gsub!(/@(-?\d+)/, 'push \1 load')
|
120
124
|
end
|
121
125
|
|
122
126
|
def gensym
|
data/lib/spitewaste/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spitewaste
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Collided Scope (collidedscope)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|