-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathspec.lisp
2776 lines (2713 loc) · 166 KB
/
spec.lisp
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; -*- Mode:Lisp; Syntax:ANSI-Common-Lisp; Coding:utf-8; Package:April -*-
;;;; spec.lisp
(in-package #:april)
"This specification defines the April language. All of the standard functions and operators and their symbols, along with the language's grammar, utilities, reserved symbols, tests and demo suite are specified here."
(let ((circular-functions ;; APL's set of circular functions called using the ○ symbol with a left argument
(vector (lambda (x) (exp (complex 0 x)))
(lambda (x) (complex 0 x))
#'conjugate #'identity (lambda (x) (- (sqrt (- (1+ (expt x 2))))))
#'atanh #'acosh #'asinh (lambda (x) (if (= -1 x) 0 (* (1+ x) (sqrt (/ (1- x) (1+ x))))))
#'atan #+ecl #'cmucl-complex-acos #+(not ecl) #'acos
#'asin (lambda (x) (sqrt (- 1 (expt x 2))))
#'sin #'cos #'tan (lambda (x) (sqrt (1+ (expt x 2))))
#'sinh #'cosh #'tanh (lambda (x) (sqrt (- (1+ (expt x 2)))))
#'realpart #'abs #'imagpart #'phase))
(coercing-indices (make-array 6 :element-type '(unsigned-byte 8)
:initial-contents '(1 2 3 21 22 23))))
;; ECL defaults to C's standard acos thus its function must be specially assigned
(defun call-circular (&optional inverse)
(lambda (value function-index)
(if (and (integerp function-index) (<= -12 function-index 12))
(let ((vector-index (+ 12 (funcall (if inverse #'- #'identity)
function-index))))
(funcall (aref circular-functions vector-index)
;; for some functions, double coercion is not needed
(if (position vector-index coercing-indices :test #'=)
value (* value 1.0d0))))
(error "Invalid argument to [○ circular]; the left argument must be an~a"
" integer between ¯12 and 12.")))))
(setf *value-composable-lexical-operators* (list #\⍨))
;; top-level specification for the April language
(specify-vex-idiom
april
;; system variables and default state of an April workspace
(system :workspace-defaults '(:index-origin 1 :print-precision 10 :division-method 0
:comparison-tolerance double-float-epsilon
:rngs (list :generators :rng (aref *rng-names* 1)))
:output-printed nil :base-state '(:output-stream '*standard-output*)
:variables *system-variables* :string-delimiters "'\"" :comment-delimiters "⍝"
:closure-wrapping "()" :function-wrapping "{}" :axis-wrapping "[]"
:negative-signs-pattern "[¯]" :number-spacers-pattern "[_]" :axis-separators ";"
:path-separators "." :supplemental-numeric-chars "._¯eEjJrR" :supplemental-token-chars "._⎕∆⍙¯"
:newline-characters (coerce '(#\Newline #\Return) 'string))
;; parameters for describing and documenting the idiom in different ways; currently, these options give
;; the order in which output from the blocks of tests is printed out for the (test) and (demo) options
(profiles (:test :lexical-functions-scalar-numeric :lexical-functions-scalar-logical
:lexical-functions-array :lexical-functions-special :lexical-operators-lateral
:lexical-operators-pivotal :lexical-statements :general-tests
:system-variable-function-tests :function-inversion-tests :namespace-tests
:printed-format-tests)
(:arbitrary-test :output-specification-tests)
(:time :lexical-functions-scalar-numeric :lexical-functions-scalar-logical
:lexical-functions-array :lexical-functions-special :lexical-operators-lateral
:lexical-operators-pivotal :lexical-statements :general-tests)
(:demo :general-tests :lexical-functions-scalar-numeric :lexical-functions-scalar-logical
:lexical-functions-array :lexical-functions-special :lexical-operators-lateral
:lexical-operators-pivotal :lexical-statements :system-variable-function-tests
:function-inversion-tests :namespace-tests :printed-format-tests))
;; utilities for compiling the language
(utilities :match-blank-character (let ((cstring (coerce '(#\ #\Tab) 'string)))
(lambda (char) (position char cstring :test #'char=)))
:match-newline-character (let ((cstring (coerce '(#\⋄ #\◊ #\Newline #\Return) 'string)))
(lambda (char) (position char cstring :test #'char=)))
;; set the language's valid blank, newline characters and token characters
:match-numeric-character
(let ((other-chars))
(lambda (char idiom)
(unless other-chars (setf other-chars (of-system idiom :supplemental-numeric-chars)))
(or (digit-char-p char) (position char other-chars :test #'char=))))
:match-token-character
(let ((other-chars))
(lambda (char idiom)
(unless other-chars (setf other-chars (of-system idiom :supplemental-token-chars)))
(or (is-alphanumeric char) (position char other-chars :test #'char=))))
;; match characters that can only appear in homogenous symbols, this is needed so that
;; things like ⍺⍺.⍵⍵, ⍺∇⍵ or ⎕NS⍬ can work without spaces between the symbols
:match-uniform-token-character (lambda (char) (position char "⍺⍵⍶⍹∇⍬" :test #'char=))
;; match characters specifically representing function/operator arguments, this is needed
;; so ⍵.path.to will work
:match-arg-token-character (lambda (char) (position char "⍺⍵⍶⍹" :test #'char=))
;; match characters used to link parts of paths together like namespace.path.to,
;; this is needed so that ⍵.path.to will work
:match-path-joining-character (let ((chars))
(lambda (char idiom)
(unless chars (setf chars (of-system idiom :path-separators)))
(position char chars :test #'char=)))
;; overloaded numeric characters may be functions or operators or may be part of a numeric token
;; depending on their context
:match-overloaded-numeric-character (lambda (char) (char= char #\.))
;; match character(s) used to separate axes
:match-axis-separating-character (let ((chars))
(lambda (char idiom)
(unless chars
(setf chars (of-system idiom :axis-separators)))
(position char chars :test #'char=)))
;; generate the string of matched closing and opening characters that wrap code sections;
;; used to identify stray closing characters such as ) without a corresponding (
:collect-delimiters
(lambda (idiom)
(let ((output) (cw (of-system idiom :closure-wrapping))
(fw (of-system idiom :function-wrapping)) (aw (of-system idiom :axis-wrapping)))
(loop :for i :from (/ (length cw) 2) :to (1- (length cw)) :do (push (aref cw i) output))
(loop :for i :from (/ (length fw) 2) :to (1- (length fw)) :do (push (aref fw i) output))
(loop :for i :from (/ (length aw) 2) :to (1- (length aw)) :do (push (aref aw i) output))
(loop :for i :below (/ (length cw) 2) :do (push (aref cw i) output))
(loop :for i :below (/ (length fw) 2) :do (push (aref fw i) output))
(loop :for i :below (/ (length aw) 2) :do (push (aref aw i) output))
(reverse (coerce output 'string))))
;; this code preprocessor removes comments, starting with each ⍝ and ending before the next newline
:prep-code-string
(lambda (idiom)
(let ((nlstring (of-system idiom :newline-characters))
(comment-delimiters (of-system idiom :comment-delimiters)))
(lambda (string)
(let ((commented) (osindex 0)
(out-string (make-string (length string) :initial-element #\ )))
(loop :for char :across string
:do (if commented (when (position char nlstring :test #'char=)
(setf commented nil
(row-major-aref out-string osindex) char
osindex (1+ osindex)))
(if (position char comment-delimiters :test #'char=)
(setf commented t)
(setf (row-major-aref out-string osindex) char
osindex (1+ osindex)))))
;; return displaced string to save time processing blanks
(make-array osindex :element-type 'character :displaced-to out-string)))))
;; handles axis strings like "'2;3;;' from 'array[2;3;;]'"
:process-axis-string
(let ((delimiters) (axis-separators) (full-len) (half-len) (nesting (vector 0 0 0)))
(lambda (string idiom)
(unless delimiters
(setf delimiters (reverse (funcall (of-utilities idiom :collect-delimiters) idiom))
full-len (length delimiters)
half-len (/ full-len 2)
axis-separators (of-system idiom :axis-separators)))
(let ((indices) (last-index) (quoted))
(loop :for i :below (length nesting) :do (setf (aref nesting i) 0))
(loop :for char :across string :counting char :into charix
:do (let ((mx (or (loop :for d :across delimiters :counting d :into dx
:when (char= d char) :do (return (- full-len -1 dx)))
0)))
(if (position char (of-system idiom :string-delimiters) :test #'char=)
(setf quoted (not quoted))
(unless quoted
(if (< half-len mx) (incf (aref nesting (- full-len mx)))
(if (<= 1 mx half-len)
(if (< 0 (aref nesting (- half-len mx)))
(decf (aref nesting (- half-len mx)))
(error "Each closing ~a must match with an opening ~a."
(aref delimiters mx)
(aref delimiters (- half-len mx))))
(when (and (position char axis-separators :test #'char=)
(zerop (loop :for ncount :across nesting
:summing ncount)))
(setq indices (cons (1- charix) indices)))))))))
(loop :for index :in (reverse (cons (length string) indices))
:counting index :into iix
:collect (make-array (- index (if last-index 1 0)
(or last-index 0))
:element-type 'character :displaced-to string
:displaced-index-offset (if last-index (1+ last-index) 0))
:do (setq last-index index)))))
;; macro to process lexical specs of functions and operators
:process-fn-op-specs #'process-fnspecs
:test-parameters '((:space unit-test-staging))
:number-formatter #'parse-apl-number-string
:format-value #'format-value
;; process system state input passed as with (april (with (:state ...)) "...")
:preprocess-state-input
(lambda (state)
(when (getf state :count-from)
(setf (getf state :index-origin) (getf state :count-from)))
state)
;; converts parts of the system state into lists that will form part of the local lexical
;; environment in which the compiled APL code runs, i.e. the (let) form into which
;; the APL-generating macros are expanded
:system-lexical-environment-interface
(lambda (state)
;; the index origin, print precision and output stream values are
;; passed into the local lexical environment
(append (list (list (find-symbol "OUTPUT-STREAM" *package-name-string*)
(or (getf state :print-to)
(second (getf state :output-stream)))))
(loop :for (key value) :on *system-variables* :by #'cddr
:collect (list (find-symbol (string-upcase key) *package-name-string*)
(or (getf state key) `(inwsd ,value))))))
:lexer-postprocess #'lexer-postprocess
:compile-form #'compile-form
:postprocess-compiled
(lambda (state &rest inline-arguments)
(lambda (form)
;; form assignment accounts for cases like (april-c "+" 1 2)
(let* ((form (if (not (and (= 1 (length form)) (characterp (first form))
(of-lexicons this-idiom (first form) :functions)))
form (list (build-call-form (first form)))))
;; operands for cases like (april-c "{⍵⍵ ⍺⍺/⍵}" #'+ #'- #(1 2 3 4 5))
(operands (when (and inline-arguments (listp (first form))
(eql 'olambda (caar form)))
(cadar form)))
(final-form (if inline-arguments
(if operands
`(a-call (a-comp :op ,(first (last form))
,(first inline-arguments)
,@(if (intersection operands '(⍵⍵ ⍹))
(list (second inline-arguments))))
,@(if (intersection operands '(⍵⍵ ⍹))
(cddr inline-arguments)
(rest inline-arguments)))
`(a-call ,(first (last form)) ,@inline-arguments))
(first (last form)))))
(append (butlast form)
(list (append (list 'a-out final-form)
(append (list :print-precision 'print-precision)
(when (getf state :unrendered) (list :unrendered t))
(when (getf state :print) (list :print-to 'output-stream))
(when (getf state :output-printed)
(list :output-printed
(getf state :output-printed))))))))))
:postprocess-value
(lambda (form state)
(append (list 'a-out form)
(append (list :print-precision 'print-precision)
(when (getf state :print) (list :print-to 'output-stream))
(when (getf state :output-printed)
(list :output-printed (getf state :output-printed))))))
:process-stored-symbol
(lambda (symbol space is-function)
(if is-function (let ((found-sym (intern symbol space)))
(when (and found-sym (boundp found-sym)
(not (fboundp found-sym)))
(makunbound found-sym))
(setf (symbol-function found-sym) #'dummy-nargument-function))
(let ((found-sym (intern symbol space)))
(when (fboundp found-sym) (fmakunbound found-sym))
(unless (and found-sym (boundp found-sym))
(proclaim (list 'special (intern symbol space)))
(set (intern symbol space) nil)))))
;; build multiple output of April expression, rendering unless (:unrendered) option is passed
:process-multiple-outputs
(lambda (outputs space &optional will-render)
(list (cons 'values (mapcar (lambda (return-var)
(let ((symbol (intern (lisp->camel-case return-var)
space)))
(if (not will-render)
symbol `(process-ns-output (vrender ,symbol)))))
outputs))))
:build-variable-declarations #'build-variable-declarations
:build-compiled-code #'build-compiled-code
:assign-val-sym 'ws-assign-val :assign-fun-sym 'ws-assign-fun)
;; specs for multi-character symbols exposed within the language
(symbols (:variable ⎕ to-output ⎕io *index-origin* ⎕pp print-precision ⎕div *division-method*
⎕ost output-stream ⎕ct *comparison-tolerance* ⎕rl *rngs*)
(:constant ⎕a *alphabet-vector* ⎕d *digit-vector* ⎕ts *apl-timestamp*)
(:function ⎕ns make-namespace ⎕cs change-namespace ⎕ty coerce-or-get-type
⎕ucs scalar-code-char ⎕fmt (format-array-uncollated print-precision)
⎕xwv external-workspace-value ⎕xwf external-workspace-function
⎕xwo external-workspace-operator))
;; APL's set of lexical functions, monadic or dyadic operations represented by a single character
(functions
(with (:name :lexical-functions-scalar-numeric)
(:tests-profile :title "Scalar Numeric Function Tests")
(:demo-profile :title "Scalar Numeric Function Demos"
:description "Scalar numeric functions change individual numeric values. They include basic arithmetic and other numeric operations, and they can be applied over arrays."))
(+ (has :titles ("Conjugate" "Add"))
(ambivalent (scalar-function conjugate)
(scalar-function +))
(meta (monadic :id 0 :inverse (ac-wrap :m (scalar-function conjugate)))
(dyadic :id 0 :commutative t :inverse (ac-wrap :d (scalar-function -))
:inverse-right (ac-wrap :d (scalar-function (reverse-op -)))
:inverse-commuted (ac-wrap :m (scalar-function (λω (/ omega 2))))))
(tests (is "+5" 5)
(is "+5J2" #C(5 -2))
(is "1+1" 2)
(is "1+1 2 3" #(2 3 4))))
(- (has :titles ("Negate" "Subtract"))
(ambivalent (scalar-function -)
(scalar-function (reverse-op -)))
(meta (monadic :id 0 :inverse (ac-wrap :m (scalar-function (reverse-op -))))
(dyadic :id 0 :inverse (ac-wrap :d (scalar-function (reverse-op -)))
:inverse-right (ac-wrap :d (scalar-function +)) :scan-alternating #'-))
(tests (is "2-1" 1)
(is "7-2 3 4" #(5 4 3))))
(× (has :titles ("Sign" "Multiply"))
(ambivalent (scalar-function signum)
(scalar-function *))
(meta (monadic :id 1)
(dyadic :id 1 :commutative t :inverse (ac-wrap :d (scalar-function /))
:inverse-right (ac-wrap :d (scalar-function (reverse-op /)))
:inverse-commuted (ac-wrap :m (scalar-function sqrt))))
(tests (is "×20 5 0 ¯7 3 ¯9" #(1 1 0 -1 1 -1))
(is "2×3" 6)
(is "4 5×8 9" #(32 45))))
(÷ (has :titles ("Reciprocal" "Divide"))
(ambivalent (scalar-function (apl-divide division-method))
(scalar-function (apl-divide division-method)))
(meta (primary :implicit-args (division-method) :scan-alternating #'/)
(monadic :id 1 :inverse (ac-wrap :m (scalar-function (apl-divide division-method))))
(dyadic :id 1 :inverse (ac-wrap :d (scalar-function (apl-divide division-method)))
:inverse-right (ac-wrap :d (scalar-function *)) :scan-alternating #'/))
(tests (is "6÷2" 3)
(is "12÷6 3 2" #(2 4 6))
(is "÷2 4 8" #(1/2 1/4 1/8))
(is "{⎕div←0 ⋄ ÷⍨⍵} 0" 1)
(is "{⎕div←1 ⋄ ÷⍨⍵} 0" 0)
(is "{⎕div←1 ⋄ ÷ ⍵} 0" 0)
(is "{⎕div←1 ⋄ 1 ÷ ⍵} 0" 0)))
(⋆ (has :titles ("Exponential" "Power") :aliases (*))
(ambivalent (scalar-function apl-exp)
(scalar-function (reverse-op :dyadic apl-expt)))
(meta (monadic :id 1 :inverse (ac-wrap :m (scalar-function apl-log)))
(dyadic :id 1 :inverse (ac-wrap :d (scalar-function apl-log))
:inverse-right (ac-wrap :d (scalar-function (λωα (apl-expt alpha (/ omega)))))))
(tests (is "⌊1000×⋆2" 7389)
(is "2⋆4" 16)
(is "⌊16⋆÷2" 4)
(is "⌊100000×⋆0J1" #C(54030 84147))))
(⍟ (has :titles ("Natural Logarithm" "Logarithm"))
(ambivalent (scalar-function apl-log)
(scalar-function apl-log))
(meta (monadic :inverse (ac-wrap :m (scalar-function apl-exp)))
(dyadic :inverse (ac-wrap :d (scalar-function (reverse-op :dyadic apl-expt)))
:inverse-right (ac-wrap :d (scalar-function (λωα (apl-expt omega (/ alpha)))))))
(tests (is "⌊1000×⍟5" 1609)
(is "⌊2⍟8" 3)))
(\| (has :titles ("Magnitude" "Residue"))
(ambivalent (scalar-function abs)
(scalar-function (apl-residue comparison-tolerance)))
(meta (primary :implicit-args (comparison-tolerance))
(monadic :id 0)
(dyadic :id 0))
(tests (is "|55" 55)
(is "|¯33" 33)
(is "8|39" 7)
(is "(3r8J12r7×⍳12)|7r2J5r9×⍳12"
#(#C(1/14 47/36) #C(1/7 47/18) #C(3/14 47/12) #C(2/7 47/9) #C(5/14 235/36) #C(3/7 47/6)
#C(1/2 329/36) #C(4/7 94/9) #C(9/14 47/4) #C(5/7 235/18) #C(11/14 517/36) #C(6/7 47/3)))))
(! (has :titles ("Factorial" "Binomial"))
(ambivalent (scalar-function sprfact)
(scalar-function binomial))
(meta (monadic)
(dyadic :id 1))
(tests (is "!5" 120)
(is "5!12" 792)
(is "∘.!⍨¯3+⍳7" #2A((1 -1 0 0 0 0 0) (0 1 0 0 0 0 0) (1 1 1 1 1 1 1) (-2 -1 0 1 2 3 4)
(3 1 0 0 1 3 6) (-4 -1 0 0 0 1 4) (5 1 0 0 0 0 1)))))
(⌈ (has :titles ("Ceiling" "Maximum"))
(ambivalent (scalar-function (apl-ceiling comparison-tolerance))
(scalar-function (reverse-op max)))
(meta (primary :implicit-args (comparison-tolerance))
(monadic)
(dyadic :id most-negative-double-float :commutative t
:inverse-commuted (ac-wrap :m (scalar-function identity))))
(tests (is "⌈1.0001" 2)
(is "⌈1.9998" 2)
(is "3⌈0 1 2 3 4 5" #(3 3 3 3 4 5))
(is "⌈21r5J3r11×⍳20"
#(#C(4 1) #C(8 1) #C(13 1) #C(17 1) #C(21 2) #C(25 2) #C(30 2) #C(34 2) #C(38 3) #C(42 3)
#C(47 3) #C(51 3) #C(55 4) #C(59 4) #C(63 5) #C(67 5) #C(72 5) #C(76 5) #C(80 5) #C(84 6)))))
(⌊ (has :titles ("Floor" "Minimum"))
(ambivalent (scalar-function (apl-floor comparison-tolerance))
(scalar-function (reverse-op min)))
(meta (primary :implicit-args (comparison-tolerance))
(monadic)
(dyadic :id most-positive-double-float :commutative t
:inverse-commuted (ac-wrap :m (scalar-function identity))))
(tests (is "⌊1.0001" 1)
(is "⌊1.9998" 1)
(is "3⌊0 1 2 3 4 5" #(0 1 2 3 3 3))
(is "⌊1.5J0.5" #C(1 1))
(is "⌊21r5J3r11×⍳20"
#(4 8 #C(12 1) #C(16 1) #C(21 1) #C(25 1) #C(29 2) #C(33 2) #C(38 2) #C(42 2) #C(46 3)
#C(50 3) #C(55 3) #C(58 4) #C(63 4) #C(67 4) #C(71 5) #C(75 5) #C(79 5) #C(84 5)))))
(? (has :titles ("Random" "Deal"))
(ambivalent (λω (make-instance 'vader-random :base omega :rng rngs :index-origin index-origin))
(λωα (make-instance 'vader-deal :base omega :argument alpha
:rng rngs :index-origin index-origin)))
(meta (primary :implicit-args (index-origin rngs)))
(tests (is "⍴5?⍴⍳5" #(5))
(is "0=+/,3<?3 3⍴2" 1)
(is "∧/,∘.=⍨⍤1⊢⍉↑{⎕RL←5 1 ⋄ 10?⍵}¨10⍴1000" 1)
(is "∧/,∘.=⍨⍤1⊢⍉↑{⎕RL←7 0 ⋄ 10?⍵}¨10⍴1000" 1)
(is "∧/,∘.=⍨⍤1⊢⍉↑{⎕RL←⍬ 2 ⋄ 10?⍵}¨10⍴1000" 0)))
(○ (has :titles ("Pi Times" "Circular"))
(ambivalent (scalar-function (λω (* omega (coerce pi 'double-float))))
(scalar-function (call-circular)))
(meta (monadic :inverse (ac-wrap :m (scalar-function (λω (/ omega pi)))))
(dyadic :inverse (ac-wrap :d (scalar-function (call-circular :inverse)))
:inverse-right (scalar-function (λωα (declare (ignore omega alpha))
(error "Inverse [○ circular] may not take an ~a"
"implicit right argument.")))))
(tests (is "⌊100000×○1" 314159)
(is "(⌊1000×1÷2⋆÷2)=⌊1000×1○○÷4" 1)
(is "⌊1000×1○⍳9" #(841 909 141 -757 -959 -280 656 989 412))
(is "⌈1 2 3○○.5 2 .25" #(1 1 1))
;; omit asin and atanh from the tests below because they
;; are not consistent across CL implementations
(is "¯11 ¯10 ¯9 9 10 11○1" #(#C(0 1) 1 1 1 1 0))
(is "⌊1000×⊃,/9 11○⊂(¯1 ¯7~⍨¯8+⍳16) ∘.○ 0 ¯2 2 ¯2J2 2J3.5"
#2A((0 1316 1316 1734 2095 1570 3141 0 2325 1064)
(0 -1444 1443 -1735 2079 0 0 0 754 1038)
(0 -1733 1732 -1880 1940 1000 0 0 2128 3607)
(0 -1108 1107 -1312 1442 0 0 0 238 215)
(1570 3141 0 2325 1064 0 -1317 1316 -1735 -2096)
(1000 0 0 2128 3607 0 1732 1732 1879 -1941)
(0 -910 909 -3421 15069 0 0 0 -1510 -6885)
(1000 -417 -417 -1566 -6897 0 0 0 3297 -15043)
(0 2185 -2186 28 -2 0 0 0 1023 1001)
(1000 2236 2236 2128 2063 0 0 0 -1880 3392)
(0 -3627 3626 1509 -3397 0 0 0 3420 -1320)
(1000 3762 3762 -1566 -3524 0 0 0 -3298 -1273)
(0 -965 964 -1024 972 0 0 0 -29 23)
(0 0 0 1879 3392 1000 2236 2236 2128 -2064)))))
(\~ (has :titles ("Not" "Without"))
(ambivalent (scalar-function binary-not)
(λωα (make-instance 'vader-without :base omega :argument alpha)))
(meta (monadic :inverse (ac-wrap :m (scalar-function binary-not))))
(tests (is "~1 0 1" #(0 1 0))
(is "1 2 3 4 5 6 7~3 5" #(1 2 4 6 7))
(is "1 2 3 4~2" #(1 3 4))
(is "(⍳9)~2 2⍴⍳9" #(5 6 7 8 9))
(is "'MACARONI'~'ALFREDO'" "MCNI"))))
(functions
(with (:name :lexical-functions-scalar-logical)
(:tests-profile :title "Scalar Logical Function Tests")
(:demo-profile :title "Scalar Logical Function Demos"
:description "Scalar logical functions compare individual values, and like scalar numeric functions they can be applied over arrays."))
(< (has :title "Less")
(dyadic (scalar-function (boolean-op (compare-by '< comparison-tolerance))
:binary-output t))
(meta (primary :implicit-args (comparison-tolerance))
(dyadic :id 0))
(tests (is "3<1 2 3 4 5" #*00011)))
(≤ (has :title "Less or Equal")
(dyadic (scalar-function (boolean-op (compare-by '<= comparison-tolerance))
:binary-output t))
(meta (primary :implicit-args (comparison-tolerance))
(dyadic :id 1))
(tests (is "3≤1 2 3 4 5" #*00111)
(is "1.0≤1.0" 1)
(is "{⎕CT←0.0001 ⋄ (1.0000000001≤⍵),(1.0000000001≤⍨⍵),1.01≤⍵} 1.0" #*110)))
(= (has :title "Equal")
(dyadic (scalar-function (boolean-op (scalar-compare comparison-tolerance))
:binary-output t))
(meta (primary :implicit-args (comparison-tolerance))
(dyadic :id 1 :commutative t))
(tests (is "3=1 2 3 4 5" #*00100)
(is "'cat'='hat'" #*011)))
(≥ (has :title "Greater or Equal")
(dyadic (scalar-function (boolean-op (compare-by '>= comparison-tolerance))
:binary-output t))
(meta (primary :implicit-args (comparison-tolerance))
(dyadic :id 1))
(tests (is "3≥1 2 3 4 5" #*11100)
(is "1.0≥1.0" 1)
(is "{⎕CT←0.0001 ⋄ (⍵≥1.0000000001),(⍵≥⍨1.0000000001),⍵≥1.01} 1.0" #*110)))
(> (has :title "Greater")
(dyadic (scalar-function (boolean-op (compare-by '> comparison-tolerance))
:binary-output t))
(meta (primary :implicit-args (comparison-tolerance))
(dyadic :id 0))
(tests (is "3>1 2 3 4 5" #*11000)))
(≠ (has :titles ("Unique Mask" "Not Equal"))
(ambivalent (λω (make-instance 'vader-umask :base omega))
(scalar-function (boolean-op (λωα (not (funcall (scalar-compare comparison-tolerance)
omega alpha))))
:binary-output t))
(meta (primary :implicit-args (comparison-tolerance))
(dyadic :id 0 :commutative t))
(tests (is "≠2 4 7 4 6 8 3 5 2 4 2 5 6 7" #*11101111000000)
(is "≠'ONE' 'TWO' 'ONE' 'THREE' 'TWO' 'THREE'" #*110100)
(IS "≠↑'ONE' 'TWO' 'ONE' 'THREE' 'TWO' 'THREE'" #*110100)
(is "3≠1 2 3 4 5" #*11011)
(is "'Harrison'≠'Bergeron'" #*11011100)))
(∧ (has :title "And" :aliases (^))
(dyadic (scalar-function (apl-lcm comparison-tolerance)))
(meta (primary :implicit-args (comparison-tolerance))
(dyadic :id 1 :commutative t))
(tests (is "0 1 0 1∧0 0 1 1" #*0001)
(is "3.2∧1.9" 60.8d0)
(is "6.3∧5.1" 107.1d0)
(is "⌈1000×1.3J2.6∧4.5J8.9" #C(-172900 232700))
(is "⌈1000×3.8J7.6∧5.2J6.8" #C(-159600 326800))))
(⍲ (has :title "Nand")
(dyadic (scalar-function (boolean-op (λωα (not (= omega alpha 1))))))
(meta (dyadic :commutative t))
(tests (is "0 1 0 1⍲0 0 1 1" #*1110)))
(∨ (has :title "Or")
(dyadic (scalar-function (apl-gcd comparison-tolerance)))
(meta (primary :implicit-args (comparison-tolerance))
(dyadic :id 0 :commutative t))
(tests (is "0 1 0 1∨0 0 1 1" #*0111)
(is "3.2∨1.9" 0.1d0)
(is "6.3∨5.1" 0.3d0)
(is "1.3J2.6∨4.5J8.9" 0.1d0)
(is "3.8J7.6∨5.2J6.8" 0.2d0)))
(⍱ (has :title "Nor")
(dyadic (scalar-function (boolean-op (λωα (= omega alpha 0)))))
(meta (dyadic :commutative t))
(tests (is "0 1 0 1⍱0 0 1 1" #*1000))))
(functions
(with (:name :lexical-functions-array)
(:tests-profile :title "Array Function Tests")
(:demo-profile :title "Array Function Demos"
:description "These functions affect entire arrays, changing their structure or deriving data from them in some way."))
(⍳ (has :titles ("Interval" "Index Of"))
(ambivalent (λω (count-to omega index-origin))
(λωα (make-instance 'vader-index :base omega :argument alpha :index-origin index-origin)))
(meta (primary :implicit-args (index-origin))
(monadic :inverse (λω (inverse-count-to omega index-origin))))
(tests (is "⍳5" #(1 2 3 4 5))
(is "⍳0" #())
(is "⍳⍴⍳5" #(1 2 3 4 5))
(is "⍳2 3" #2A((#*11 #(1 2) #(1 3)) (#(2 1) #(2 2) #(2 3))))
(is "⍳4 3" #2A((#*11 #(1 2) #(1 3)) (#(2 1) #(2 2) #(2 3))
(#(3 1) #(3 2) #(3 3)) (#(4 1) #(4 2) #(4 3))))
(is "⍳2 4 3" #3A(((#*111 #(1 1 2) #(1 1 3)) (#(1 2 1) #(1 2 2) #(1 2 3))
(#(1 3 1) #(1 3 2) #(1 3 3)) (#(1 4 1) #(1 4 2) #(1 4 3)))
((#(2 1 1) #(2 1 2) #(2 1 3)) (#(2 2 1) #(2 2 2) #(2 2 3))
(#(2 3 1) #(2 3 2) #(2 3 3)) (#(2 4 1) #(2 4 2) #(2 4 3)))))
(is "2×1-⍨⍳4" #(0 2 4 6))
(is "¯1-⍳8" #(-2 -3 -4 -5 -6 -7 -8 -9))
(is "((,2)⍳3),2 3⍳4" #(2 3))
(is "(,3)⍳⍳4" #(2 2 1 2))
(is "2 4⍳⍳5" #(3 1 3 2 3))
(is "'aabc'⍳'b'" 3)
(is "'THIS' 'IS' 'A' 'TEST'⍳'IS' 'IT'" #(2 5))
(is "'RAT' 'CAT' 'DOG'⍳⊂'DOG'" 3)
(is "(3 3⍴'CATRATDOG')⍳'RAT'" 2)
(is "(3 3⍴'CATRATDOG')⍳4 3⍴'RATDOGPIG'" #(2 3 4 2))
(is "2÷⍨⎕IO-⍨¯10+⍳21"
#(-5 -9/2 -4 -7/2 -3 -5/2 -2 -3/2 -1 -1/2 0 1/2 1 3/2 2 5/2 3 7/2 4 9/2 5))))
(⍴ (has :titles ("Shape" "Reshape"))
(ambivalent (λω (make-instance 'vader-shape :base omega))
(λωα (make-instance 'vader-reshape :base omega :argument alpha)))
(tests (is "⍴1" #())
(is "⍴1 2 3" #(3))
(is "⍴3 5⍴1" #(3 5))
(is "⍴⍴3 4⍴2" #(2))
(is "⍴⍴⍴4 5 6 7⍴3" #(1))
(is "⍴⍬" #(0))
(is "3⍴2" #(2 2 2))
(is "3⍴3" #(3 3 3))
(is "4 5⍴⍳3" #2A((1 2 3 1 2) (3 1 2 3 1) (2 3 1 2 3) (1 2 3 1 2)))
(is "⍬⍴5" 5)
(is "⍬⍴5 6 7" 5)
(is "⍬⍴(4 5) 6" #0A#(4 5))
(is "3⍴0⍴⊂2 2⍴5" #(#2A((0 0) (0 0)) #2A((0 0) (0 0)) #2A((0 0) (0 0))))
(is "2 2⍴0⍴3⍴⊂2 3⍴5" #2A((#2A((0 0 0)(0 0 0)) #2A((0 0 0)(0 0 0)))
(#2A((0 0 0)(0 0 0)) #2A((0 0 0)(0 0 0)))))
(is "(,0)⍴0 0⍴0" #())))
(⌷ (has :title "Index")
(dyadic (at-index index-origin axes))
(meta (primary :axes axes :implicit-args (index-origin))
(dyadic :selective-assignment-compatible t :selective-assignment-function :index))
(tests (is "1⌷3" 3)
(is "3⌷2 4 6 8 10" 6)
(is "3⌷⍳9" 3)
(is "2 2⌷4 5⍴⍳9" 7)
(is "2 3 4⌷4 5 6⍴⍳9" 1)
(is "1 3⌷2 3 4⍴⍳5" #(4 5 1 2))
(is "1 3⌷[1 3]2 3 4⍴⍳5" #(3 2 1))
(is "1⌷[2]3 3⍴⍳9" #(1 4 7))
(is "(⊂4 5 2 6 3 7 1)⌷'MARANGA'" "ANAGRAM")
(is "(⍬,5) 1⌷5 5⍴⍳25" #(21))
(is "(5 4) 1⌷5 5⍴⍳25" #(21 16))))
(≡ (has :titles ("Depth" "Match"))
(ambivalent (λω (make-instance 'vader-depth :base omega))
(λωα (make-instance 'vader-compare :base (vector omega alpha)
:comparison-tolerance comparison-tolerance)))
(meta (primary :implicit-args (comparison-tolerance)))
(tests (is "≡1" 0)
(is "≡⍳3" 1)
(is "≡(1 2)(3 4)" 2)
(is "≡1 (2 3) (4 5 (6 7)) 8" -3)
(IS "≡↓↓2 3⍴⍳6" 3)
(IS "≡↓↓↓2 3⍴⍳6" 4)
(is "3≡3" 1)
(is "4≡2" 0)
(is "⍬≡⍬" 1)
(is "''≡''" 1)
(is "⍬≡''" 0)
(is "⍬≡1↓'a'" 0)
(is "('a',⍬)≡1↑'amy'" 1)
(is "v←1 2 3 ⋄ (⊂v)≡⊂1 2 3" 1)))
(≢ (has :titles ("First Dimension" "Not Match"))
(ambivalent (λω (make-instance 'vader-first-dim :base omega))
(λωα (make-instance 'vader-compare :base (vector omega alpha) :inverse t
:comparison-tolerance comparison-tolerance)))
(meta (primary :implicit-args (comparison-tolerance)))
(tests (is "≢2" 1)
(is "≢1 2 3" 3)
(is "≢2 3 4⍴⍳9" 2)
(is "5≢5" 0)
(is "3≢1" 1)))
(∊ (has :titles ("Enlist" "Membership"))
(ambivalent (λω (make-instance 'vader-enlist :base omega))
(λωα (make-instance 'vader-membership :base alpha :argument omega)))
(tests (is "∊2" #(2))
(is "∊2 2 2⍴⍳9" #(1 2 3 4 5 6 7 8))
(is "∊⊂2 3" #(2 3))
(is "∊1 2 (⊂3 4) 5 6 (7 8)" #(1 2 3 4 5 6 7 8))
(is "∊1⍴⊂⍬,1" #(1))
(is "∊'a'" "a")
(is "2 3∊2" #*10)
(is "3∊3 4 5" 1)
(is "2 5 7∊1 2 3 4 5" #*110)
(is "'IS' 'IT' ∊ 'THIS' 'IS' 'A' 'TEST'" #*10)
(is "1∊3 3⍴⍳9" 1)
(is "(1⍴1)∊3 3⍴⍳9" #(1))
(is "∊(⊂⍬),⊂,3" #(3))
(is "1 2 3 4 8∊⍨3 3⍴⍳9" #2A((1 1 1) (1 0 0) (0 1 0)))))
(⍷ (has :title "Find")
(dyadic (λωα (make-instance 'vader-find :base omega :argument alpha)))
(tests (is "5⍷5" 1)
(is "2⍷3 4⍴⍳9" #2A((0 1 0 0) (0 0 0 0) (0 0 1 0)))
(is "(2 2⍴6 7 1 2)⍷2 3 4⍴⍳9" #3A(((0 0 0 0) (0 1 0 0) (0 0 0 0))
((0 0 1 0) (0 0 0 0) (0 0 0 0))))))
(⍸ (has :titles ("Where" "Interval Index"))
(ambivalent (λω (make-instance 'vader-where :base omega :index-origin index-origin))
(λωα (make-instance 'vader-interval-index
:base omega :argument alpha :index-origin index-origin)))
(meta (primary :implicit-args (index-origin))
(monadic :inverse (λω (make-instance 'vader-inverse-where
:base omega :index-origin index-origin))))
(tests (is "⍸1" #(#()))
(is "⍸0" #())
(is "⍸0 0 1 0 1 0 0 1 1 0" #(3 5 8 9))
(is "⍸3=2 3 4⍴⍳9" #(#(1 1 3) #(1 3 4) #(2 3 1)))
(is "⍸(2 3 4⍴⍳9)∊3 5" #(#(1 1 3) #(1 2 1) #(1 3 4) #(2 1 2) #(2 3 1) #(2 3 3)))
(is "⍸1 2 3" #(1 2 2 3 3 3))
(is "⍸3 3 ⍴ 0 0 1 0 1 1" #(#(1 3) #(2 2) #(2 3) #(3 3)))
(is "2 4 6 8⍸3" 1)
(is "10 20 30 40⍸5 12 19 24 35 42 51" #(0 1 1 2 3 4 4))
(is "(2 5⍴'RADIUS')⍸3 4 5⍴'BOXCAR'" #2A((0 1 0 0) (2 0 0 1) (0 0 2 0)))
(is "(2 3 5⍴'ABCDEFHIJKLM')⍸3 3 5⍴'BOREAL'" #(1 2 1))))
(\, (has :titles ("Ravel" "Catenate or Laminate"))
(ambivalent (λω (make-instance 'vader-pare :base omega :index-origin index-origin
:axis (first axes)))
(λωα (make-instance
'vader-catenate :base (if (eq omega :arg-vector)
alpha (vector alpha omega))
:index-origin index-origin
:axis (or (first axes) :last))))
(meta (primary :axes axes :implicit-args (index-origin))
(dyadic :on-axis :last :id #()))
(tests (is ",5" #(5))
(is ",3 4⍴⍳9" #(1 2 3 4 5 6 7 8 9 1 2 3))
(is ",↓⍬,9" #(#(9)))
(is ",[1]3 3⍴⍳9" #2A((1 2 3) (4 5 6) (7 8 9)))
(is ",[⍬,1]3 3⍴⍳9" #2A((1 2 3) (4 5 6) (7 8 9)))
(is ",[0.5]3 4⍴⍳9" #3A(((1 2 3 4) (5 6 7 8) (9 1 2 3))))
(is ",[1.5]3 4⍴⍳9" #3A(((1 2 3 4)) ((5 6 7 8)) ((9 1 2 3))))
(is ",[2.5]3 4⍴⍳9" #3A(((1) (2) (3) (4)) ((5) (6) (7) (8)) ((9) (1) (2) (3))))
(is ",[1 2]2 3 3⍴⍳12" #2A((1 2 3) (4 5 6) (7 8 9) (10 11 12) (1 2 3) (4 5 6)))
(is ",[2 3]2 3 3⍴⍳12" #2A((1 2 3 4 5 6 7 8 9) (10 11 12 1 2 3 4 5 6)))
(is ",[1 2 3]2 3 3⍴⍳12" #(1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6))
(is "⊃,[1]/(⊂3 3)⍴¨⍳5" #2A((1 1 1) (1 1 1) (1 1 1) (2 2 2) (2 2 2) (2 2 2)
(3 3 3) (3 3 3) (3 3 3) (4 4 4) (4 4 4) (4 4 4)
(5 5 5) (5 5 5) (5 5 5)))
(is "⊃,[2]/(⊂3 3)⍴¨⍳5" #2A((1 1 1 2 2 2 3 3 3 4 4 4 5 5 5)
(1 1 1 2 2 2 3 3 3 4 4 4 5 5 5)
(1 1 1 2 2 2 3 3 3 4 4 4 5 5 5)))
(is ",[⍬]5" #(5))
(is ",[⍬]⍳5" #2A((1) (2) (3) (4) (5)))
(is "5 6,3" #(5 6 3))
(is "2,⍳3" #(2 1 2 3))
(is "0,3 4⍴⍳9" #2A((0 1 2 3 4) (0 5 6 7 8) (0 9 1 2 3)))
(is "⍬,⍳5" #(1 2 3 4 5))
(is "⍬,3" #(3))
(is "'a',⍬" "a")
(is "↓(2 2⍴'a'),'*'" #("aa*" "aa*"))
(is "0,[1]3 4⍴⍳9" #2A((0 0 0 0) (1 2 3 4) (5 6 7 8) (9 1 2 3)))
(is "(3 6⍴⍳6),3 4⍴⍳9" #2A((1 2 3 4 5 6 1 2 3 4) (1 2 3 4 5 6 5 6 7 8)
(1 2 3 4 5 6 9 1 2 3)))
(is "(5 4⍴⍳6),[1]3 4⍴⍳9" #2A((1 2 3 4) (5 6 1 2) (3 4 5 6) (1 2 3 4)
(5 6 1 2) (1 2 3 4) (5 6 7 8) (9 1 2 3)))
(is "(6 7 8 9 0),⍪1 2 3 4 5" #2A((6 1) (7 2) (8 3) (9 4) (0 5)))
(is "(2 3 4⍴⍳5),2 3⍴9" #3A(((1 2 3 4 9) (5 1 2 3 9) (4 5 1 2 9))
((3 4 5 1 9) (2 3 4 5 9) (1 2 3 4 9))))
(is "(4 4⍴5),4 4 4⍴3" #3A(((5 3 3 3 3) (5 3 3 3 3) (5 3 3 3 3) (5 3 3 3 3))
((5 3 3 3 3) (5 3 3 3 3) (5 3 3 3 3) (5 3 3 3 3))
((5 3 3 3 3) (5 3 3 3 3) (5 3 3 3 3) (5 3 3 3 3))
((5 3 3 3 3) (5 3 3 3 3) (5 3 3 3 3) (5 3 3 3 3))))
(is "1 2 3,4 5 6" #(1 2 3 4 5 6))
(is "1 2 3,[1]4 5 6" #(1 2 3 4 5 6))
(is "(3 4⍴5),[1]2 3 4⍴9" #3A(((5 5 5 5) (5 5 5 5) (5 5 5 5))
((9 9 9 9) (9 9 9 9) (9 9 9 9))
((9 9 9 9) (9 9 9 9) (9 9 9 9))))
(is "(2 4⍴5),[2]2 3 4⍴9" #3A(((5 5 5 5) (9 9 9 9) (9 9 9 9) (9 9 9 9))
((5 5 5 5) (9 9 9 9) (9 9 9 9) (9 9 9 9))))
(is "(2 3⍴5),[3]2 3 4⍴9" #3A(((5 9 9 9 9) (5 9 9 9 9) (5 9 9 9 9))
((5 9 9 9 9) (5 9 9 9 9) (5 9 9 9 9))))
(is "1 2 3 4,[0.5]1 2 3 4" #2A((1 2 3 4) (1 2 3 4)))
(is "1 2 3 4,[1.5]1 2 3 4" #2A((1 1) (2 2) (3 3) (4 4)))
(is "(2 3⍴⍳9),[0.5]2 3⍴⍳9" #3A(((1 2 3) (4 5 6)) ((1 2 3) (4 5 6))))
(is "(2 3⍴⍳9),[2.5]2 3⍴⍳9" #3A(((1 1) (2 2) (3 3)) ((4 4) (5 5) (6 6))))
(is "'UNDER',[1.0]'-'" "UNDER-")
(is "↓'UNDER',[1r2]'-'" #("UNDER"
"-----"))
(is "↓'HELLO',[1.5]'.'" #("H." "E." "L." "L." "O."))
(is "(8+2 2 2⍴⍳8),[1.5]2 2 2⍴⍳8" #4A((((9 10) (11 12)) ((1 2) (3 4)))
(((13 14) (15 16)) ((5 6) (7 8)))))
(is "(8+2 2 2⍴⍳8),[5r2]2 2 2⍴⍳8" #4A((((9 10) (1 2)) ((11 12) (3 4)))
(((13 14) (5 6)) ((15 16) (7 8)))))
(is "(8+2 2 2⍴⍳8),[0.5]2 2 2⍴⍳8" #4A((((9 10) (11 12)) ((13 14) (15 16)))
(((1 2) (3 4)) ((5 6) (7 8)))))))
(⍪ (has :titles ("Table" "Catenate First"))
(ambivalent (λω (make-instance 'vader-pare :base omega :index-origin index-origin
:axis :tabulate))
(λωα (make-instance
'vader-catenate :base (if (eq omega :arg-vector)
alpha (vector alpha omega))
:index-origin index-origin
:axis (or (first axes) index-origin))))
(meta (primary :axes axes :implicit-args (index-origin))
(dyadic :on-axis :first))
(tests (is "⍪4" #2A((4)))
(is "⍪'MAKE'" #2A((#\M) (#\A) (#\K) (#\E)))
(is "⍪3 4⍴⍳9" #2A((1 2 3 4) (5 6 7 8) (9 1 2 3)))
(is "⍪2 3 4⍴⍳24" #2A((1 2 3 4 5 6 7 8 9 10 11 12)
(13 14 15 16 17 18 19 20 21 22 23 24)))
(is "2⍪⍳4" #(2 1 2 3 4))
(is "(2 3⍴⍳6)⍪3" #2A((1 2 3) (4 5 6) (3 3 3)))
(is "0⍪3 4⍴⍳9" #2A((0 0 0 0) (1 2 3 4) (5 6 7 8) (9 1 2 3)))
(is "0⍪[2]3 4⍴⍳9" #2A((0 1 2 3 4) (0 5 6 7 8) (0 9 1 2 3)))
(is "(3⍴5)⍪3 3⍴3" #2A((5 5 5) (3 3 3) (3 3 3) (3 3 3)))
(is "(5 4⍴⍳6)⍪3 4⍴⍳9" #2A((1 2 3 4) (5 6 1 2) (3 4 5 6) (1 2 3 4)
(5 6 1 2) (1 2 3 4) (5 6 7 8) (9 1 2 3)))
(is "(3 6⍴⍳6)⍪[2]3 4⍴⍳9" #2A((1 2 3 4 5 6 1 2 3 4) (1 2 3 4 5 6 5 6 7 8)
(1 2 3 4 5 6 9 1 2 3)))))
(↑ (has :titles ("Mix" "Take"))
(ambivalent (λω (make-instance 'vader-mix :base omega :index-origin index-origin
:axis (or (first axes) :last)))
(λωα (make-instance
'vader-section :base omega :argument alpha
:index-origin index-origin :axis (or (first axes) :last))))
(meta (primary :axes axes :implicit-args (index-origin))
(monadic :inverse (λω (make-instance 'vader-split :base omega :index-origin index-origin
:axis (or (first axes) :last))))
(dyadic :on-axis :last :selective-assignment-compatible t
:selective-assignment-function t))
(tests (is "↑2" 2)
(is "↑'a'" #\a)
(is "↑⍬" #())
(is "⍴1↑⍳3" #*1)
(is "↑⊂2 4" #(2 4))
(is "↑⊂⊂⍳5" #0A#(1 2 3 4 5))
(is "↑(1)(1 2)(1 2 3)" #2A((1 0 0) (1 2 0) (1 2 3)))
(is "↑[0.5](1)(1 2)(1 2 3)" #2A((1 1 1) (0 2 2) (0 0 3)))
(is "↑(2 3⍴⍳5)(4 2⍴⍳8)" #3A(((1 2 3) (4 5 1) (0 0 0) (0 0 0))
((1 2 0) (3 4 0) (5 6 0) (7 8 0))))
(is "↑(2 5⍴⍳9)(3 2 1)(4 3⍴⍳8)" #3A(((1 2 3 4 5) (6 7 8 9 1) (0 0 0 0 0) (0 0 0 0 0))
((3 2 1 0 0) (0 0 0 0 0) (0 0 0 0 0) (0 0 0 0 0))
((1 2 3 0 0) (4 5 6 0 0) (7 8 1 0 0) (2 3 4 0 0))))
(is "↑[0.5](2 3⍴⍳5)(4 2⍴⍳8)" #3A(((1 1) (2 2) (3 0)) ((4 3) (5 4) (1 0))
((0 5) (0 6) (0 0)) ((0 7) (0 8) (0 0))))
(is "↑[1.5](2 3⍴⍳5)(4 2⍴⍳8)" #3A(((1 2 3) (4 5 1) (0 0 0) (0 0 0))
((1 2 0) (3 4 0) (5 6 0) (7 8 0))))
(is "↑[0.5]2 3⍴(2 5⍴⍳9)(4 3 2 1)(4 3⍴⍳8)"
#4A((((1 4 1) (1 4 1)) ((2 3 2) (2 3 2)) ((3 2 3) (3 2 3)) ((4 1 0) (4 1 0)) ((5 0 0) (5 0 0)))
(((6 0 4) (6 0 4)) ((7 0 5) (7 0 5)) ((8 0 6) (8 0 6)) ((9 0 0) (9 0 0)) ((1 0 0) (1 0 0)))
(((0 0 7) (0 0 7)) ((0 0 8) (0 0 8)) ((0 0 1) (0 0 1)) ((0 0 0) (0 0 0)) ((0 0 0) (0 0 0)))
(((0 0 2) (0 0 2)) ((0 0 3) (0 0 3)) ((0 0 4) (0 0 4)) ((0 0 0) (0 0 0)) ((0 0 0) (0 0 0)))))
(is "↑[1.5]2 3⍴(2 5⍴⍳9)(4 3 2 1)(4 3⍴⍳8)"
#4A((((1 4 1) (2 3 2) (3 2 3) (4 1 0) (5 0 0)) ((6 0 4) (7 0 5) (8 0 6) (9 0 0) (1 0 0))
((0 0 7) (0 0 8) (0 0 1) (0 0 0) (0 0 0)) ((0 0 2) (0 0 3) (0 0 4) (0 0 0) (0 0 0)))
(((1 4 1) (2 3 2) (3 2 3) (4 1 0) (5 0 0)) ((6 0 4) (7 0 5) (8 0 6) (9 0 0) (1 0 0))
((0 0 7) (0 0 8) (0 0 1) (0 0 0) (0 0 0)) ((0 0 2) (0 0 3) (0 0 4) (0 0 0) (0 0 0)))))
(is "↑[2.5]2 3⍴(2 5⍴⍳9)(4 3 2 1)(4 3⍴⍳8)"
#4A((((1 2 3 4 5) (6 7 8 9 1) (0 0 0 0 0) (0 0 0 0 0))
((4 3 2 1 0) (0 0 0 0 0) (0 0 0 0 0) (0 0 0 0 0))
((1 2 3 0 0) (4 5 6 0 0) (7 8 1 0 0) (2 3 4 0 0)))
(((1 2 3 4 5) (6 7 8 9 1) (0 0 0 0 0) (0 0 0 0 0))
((4 3 2 1 0) (0 0 0 0 0) (0 0 0 0 0) (0 0 0 0 0))
((1 2 3 0 0) (4 5 6 0 0) (7 8 1 0 0) (2 3 4 0 0)))))
(is "↑2 2 2⍴(1)(1 2)(3 4)(1 2 3)" #4A((((1 0 0) (1 2 0)) ((3 4 0) (1 2 3)))
(((1 0 0) (1 2 0)) ((3 4 0) (1 2 3)))))
(is "2↑2" #(2 0))
(is " 2 2↑5" #2A((5 0) (0 0)))
(is " 2 ¯2↑5" #2A((0 5) (0 0)))
(is " 3 ¯2↑5" #2A((0 5) (0 0) (0 0)))
(is "¯3 2↑5" #2A((0 0) (0 0) (5 0)))
(is " 2 ¯5↑5" #2A((0 0 0 0 5) (0 0 0 0 0)))
(is " 6 6↑¯3 2↑5" #2A((0 0 0 0 0 0) (0 0 0 0 0 0) (5 0 0 0 0 0)
(0 0 0 0 0 0) (0 0 0 0 0 0) (0 0 0 0 0 0)))
(is " 6 ¯6↑¯3 2↑5" #2A((0 0 0 0 0 0) (0 0 0 0 0 0) (0 0 0 0 5 0)
(0 0 0 0 0 0) (0 0 0 0 0 0) (0 0 0 0 0 0)))
(is "¯6 6↑¯3 2↑5" #2A((0 0 0 0 0 0) (0 0 0 0 0 0) (0 0 0 0 0 0)
(0 0 0 0 0 0) (0 0 0 0 0 0) (5 0 0 0 0 0)))
(is "¯6 ¯6↑¯3 2↑5" #2A((0 0 0 0 0 0) (0 0 0 0 0 0) (0 0 0 0 0 0)
(0 0 0 0 0 0) (0 0 0 0 0 0) (0 0 0 0 5 0)))
(is "3↑⍳9" #(1 2 3))
(is "¯1↑⍳5" #(5))
(is "3↑'abcdef'" "abc")
(is "8↑'a',1 2 3" #(#\a 1 2 3 #\ #\ #\ #\ ))
(is "8↑1 2,'ab',3 4" #(1 2 #\a #\b 3 4 0 0))
(is "3↑''" " ")
(is "3↑⍬" #(0 0 0))
(is "0↑⍬" #())
(is "0 0↑⍬" #2A())
(is "3↑⊂3 3⍴5" #(#2A((5 5 5) (5 5 5) (5 5 5)) #2A((0 0 0) (0 0 0) (0 0 0))
#2A((0 0 0) (0 0 0) (0 0 0))))
(is "¯5↑⊂1 2" #(#(0 0) #(0 0) #(0 0) #(0 0) #(1 2)))
(is "3↑0↑3⍴⊂3 3⍴5" #(#2A((0 0 0) (0 0 0) (0 0 0)) #2A((0 0 0) (0 0 0) (0 0 0))
#2A((0 0 0) (0 0 0) (0 0 0))))
(is "2 3 4↑4 5 6⍴⍳9" #3A(((1 2 3 4) (7 8 9 1) (4 5 6 7))
((4 5 6 7) (1 2 3 4) (7 8 9 1))))
(is "2 ¯2 ¯2↑4 5 6⍴⍳9" #3A(((5 6) (2 3)) ((8 9) (5 6))))
(is "5 ¯5↑(3 3⍴⍳9)∊1 2 3 4 8" #2A((0 0 1 1 1) (0 0 1 0 0) (0 0 0 1 0) (0 0 0 0 0) (0 0 0 0 0)))
(is "2 ¯2↑2 2⍴⍳4" #2A((1 2) (3 4)))
(is "2 ¯3↑3 4⍴⍳12" #2A((2 3 4) (6 7 8)))
(is "2 ¯5↑3 4⍴⍳12" #2A((0 1 2 3 4) (0 5 6 7 8)))
(is "1↑3 4⍴⍳12" #2A((1 2 3 4)))
(is "1↓3 4⍴⍳12" #2A((5 6 7 8) (9 10 11 12)))
(is "1↑[1]2 3 4⍴⍳9" #3A(((1 2 3 4) (5 6 7 8) (9 1 2 3))))
(is "1↑[2]2 3 4⍴⍳9" #3A(((1 2 3 4)) ((4 5 6 7))))
(is "2↑[2]2 3 4⍴⍳9" #3A(((1 2 3 4) (5 6 7 8)) ((4 5 6 7) (8 9 1 2))))
(is "2↑[3]2 3 4⍴⍳9" #3A(((1 2) (5 6) (9 1)) ((4 5) (8 9) (3 4))))
(is "2 2↑[2 3]3 4 5⍴⍳9" #3A(((1 2) (6 7)) ((3 4) (8 9)) ((5 6) (1 2))))
(is "0↑4 5 6" #())
(is "0↑'a' 5 6" "")
(is "4↑(3 4⍴⍳12) 8 9" #(#2A((1 2 3 4) (5 6 7 8) (9 10 11 12)) 8 9
#2A((0 0 0 0) (0 0 0 0) (0 0 0 0))))
(is "6↑(⊂3 4⍴⍳9) 1 2" #(#0A#2A((1 2 3 4) (5 6 7 8) (9 1 2 3)) 1 2
#0A#2A((0 0 0 0) (0 0 0 0) (0 0 0 0))
#0A#2A((0 0 0 0) (0 0 0 0) (0 0 0 0))
#0A#2A((0 0 0 0) (0 0 0 0) (0 0 0 0))))
(is "⍴0↑3 4 5⍴5" #(0 4 5))
(is "⍴0 0↑3 4 5⍴5" #(0 0 5))
(is "3↑0↑⊂2 3⍴5" #(#2A((0 0 0) (0 0 0)) #2A((0 0 0) (0 0 0)) #2A((0 0 0) (0 0 0))))
(is "4↑0↑⊂2 2⍴(⊂2 2⍴⍳4) 2 3" #(#2A((#0A#2A((0 0) (0 0)) 0) (0 #0A#2A((0 0) (0 0))))
#2A((#0A#2A((0 0) (0 0)) 0) (0 #0A#2A((0 0) (0 0))))
#2A((#0A#2A((0 0) (0 0)) 0) (0 #0A#2A((0 0) (0 0))))
#2A((#0A#2A((0 0) (0 0)) 0) (0 #0A#2A((0 0) (0 0))))))
(is "2↑⍬ ⍬ ⍬ ⍬ ⍬" #(#() #()))
(is "8↑3⍴⊂0 0 0⍴1" #(#3A() #3A() #3A() #3A() #3A() #3A() #3A() #3A()))
(is "1↑2 3 4⍴⍳9" #3A(((1 2 3 4) (5 6 7 8) (9 1 2 3))))
(is "1 2↑2 3 4⍴⍳9" #3A(((1 2 3 4) (5 6 7 8))))
(is "2 2 2↑1 0 2⍴⍳30" #3A(((0 0) (0 0)) ((0 0) (0 0))))
(is "5 5↑3 3⍴1" #2A((1 1 1 0 0) (1 1 1 0 0) (1 1 1 0 0) (0 0 0 0 0) (0 0 0 0 0)))
(is "(¯5↑1),(,¯5)↑1" #*0000100001)
(is "4 3↑1 1↓4 5⍴⍳20" #2A((7 8 9) (12 13 14) (17 18 19) (0 0 0)))
(is "2 2↑[2 3]3 4 5↑4 5 6⍴⍳9" #3A(((1 2) (7 8)) ((4 5) (1 2)) ((7 8) (4 5))))
(is "¯2 ¯2↑[2 3]3 4 5↑4 5 6⍴⍳9" #3A(((7 8) (4 5)) ((1 2) (7 8)) ((4 5) (1 2))))
(is "¯2 ¯2↑[2 3]3 4 8↑3 4 5↑4 5 6⍴⍳9" #3A(((0 0) (0 0)) ((0 0) (0 0)) ((0 0) (0 0))))
(is "¯11↑[3]1 4 8↑3 4 5↑4 5 6⍴⍳9"
#3A(((0 0 0 1 2 3 4 5 0 0 0) (0 0 0 7 8 9 1 2 0 0 0) (0 0 0 4 5 6 7 8 0 0 0)
(0 0 0 1 2 3 4 5 0 0 0))))
(is "2↑[3]¯11↑[3]1 4 8↑3 4 5↑4 5 6⍴⍳9" #3A(((0 0) (0 0) (0 0) (0 0))))
(is "2 3↑¯2 ¯2↑1 1⍴5" #2A((0 0 0) (0 5 0)))
(is "2 3↑¯2 ¯4↑1 1⍴5" #2A((0 0 0) (0 0 0)))))
(↓ (has :titles ("Split" "Drop"))
(ambivalent (λω (make-instance 'vader-split :base omega :index-origin index-origin
:axis (or (first axes) :last)))
(λωα (make-instance
'vader-section :base omega :argument alpha :index-origin index-origin
:inverse t :axis (or (first axes) :last))))
(meta (primary :axes axes :implicit-args (index-origin))
(monadic :on-axis :last
:inverse (λωχ (make-instance 'vader-mix :base omega :index-origin index-origin
:axis (or (first axes) :last))))
(dyadic :on-axis :last :selective-assignment-compatible t :selective-assignment-function t))
(tests (is "↓5" 5)
(is "↓'b'" #\b)
(is "↓⍳5" #0A#(1 2 3 4 5))
(is "↓3 4⍴⍳9" #(#(1 2 3 4) #(5 6 7 8) #(9 1 2 3)))
(is "↓[1]3 4⍴⍳9" #(#(1 5 9) #(2 6 1) #(3 7 2) #(4 8 3)))
(is "↓[3]3 4 5⍴⍳9" #2A((#(1 2 3 4 5) #(6 7 8 9 1) #(2 3 4 5 6) #(7 8 9 1 2))
(#(3 4 5 6 7) #(8 9 1 2 3) #(4 5 6 7 8) #(9 1 2 3 4))
(#(5 6 7 8 9) #(1 2 3 4 5) #(6 7 8 9 1) #(2 3 4 5 6))))
(is "↓2 2⍴⍳4" #(#(1 2) #(3 4)))
(is "↓↓2 2⍴⍳4" #0A#(#(1 2) #(3 4)))
(is "↓↓↓2 2⍴⍳4" #0A#0A#(#(1 2) #(3 4)))
(is "1↓2" #())
(is "2↓3" #())
(is "2↓⍳9" #(3 4 5 6 7 8 9))
(is "4↓⍳9" #(5 6 7 8 9))
(is "3↓'abcdef'" "def")
(is "1↓'a'" "")
(is "2↓'ab'" "")
(is "2 2 2↓4 5 6⍴⍳9" #3A(((3 4 5 6) (9 1 2 3) (6 7 8 9))
((6 7 8 9) (3 4 5 6) (9 1 2 3))))
(is "1↓[1]2 3 4⍴⍳9" #3A(((4 5 6 7) (8 9 1 2) (3 4 5 6))))
(is "1↓[2]2 3 4⍴⍳9" #3A(((5 6 7 8) (9 1 2 3)) ((8 9 1 2) (3 4 5 6))))
(is "2↓[2]2 3 4⍴⍳9" #3A(((9 1 2 3)) ((3 4 5 6))))
(is "2↓[3]2 3 4⍴⍳9" #3A(((3 4) (7 8) (2 3)) ((6 7) (1 2) (5 6))))
(is "2 2↓[2 3]3 4 5⍴⍳9" #3A(((4 5 6) (9 1 2)) ((6 7 8) (2 3 4)) ((8 9 1) (4 5 6))))
(is "¯2↓⍳9" #(1 2 3 4 5 6 7))
(is "¯2 ¯2↓5 8⍴⍳9" #2A((1 2 3 4 5 6) (9 1 2 3 4 5) (8 9 1 2 3 4)))
(is "4 5↓2 3⍴1" #2A())
(is "1↓2 3 4⍴⍳9" #3A(((4 5 6 7) (8 9 1 2) (3 4 5 6))))
(is "1 1↓2 3 4⍴⍳9" #3A(((8 9 1 2) (3 4 5 6))))
(is "1↓¯1↓' abcdefg'" "abcdef")
(is "2 2↓[2 3]3 4 8↑3 4 5↑4 5 6⍴⍳9" #3A(((6 7 8 0 0 0) (3 4 5 0 0 0))
((9 1 2 0 0 0) (6 7 8 0 0 0))
((3 4 5 0 0 0) (9 1 2 0 0 0))))
(is "¯2 ¯2↓[2 3]3 4 8↑3 4 5↑4 5 6⍴⍳9" #3A(((1 2 3 4 5 0) (7 8 9 1 2 0))
((4 5 6 7 8 0) (1 2 3 4 5 0))
((7 8 9 1 2 0) (4 5 6 7 8 0))))))
(⊂ (has :titles ("Enclose" "Partitioned Enclose"))
(ambivalent (λω (make-instance 'vader-enclose :base omega :index-origin index-origin
:axis (first axes)))
(λωα (make-instance 'vader-enclose :argument alpha :index-origin index-origin
:base omega :axis (first axes))))
(meta (primary :axes axes :implicit-args (index-origin)))
(tests (is "⊂2" 2)
(is "(⊂2)=2" 1)
(is "(⊂'a')='a'" 1)
(is "⊂⍳5" #0A#(1 2 3 4 5))
(is "1+⊂⍳5" #0A#(2 3 4 5 6))
(is "⊂'abc'" #0A"abc")
(is "≡⊂5 5" 2)
(is "≡⊂⊂5 5" 3)
(is "≡⊂⊂⊂5 5" 4)
(is "1,⊂3 4⍴⍳7" #(1 #2A((1 2 3 4) (5 6 7 1) (2 3 4 5))))
(is "⊂[⍬]⍳3" #(1 2 3))
(is "⊂[3]2 3 4⍴'GRAYGOLDBLUESILKWOOLYARN'"
#2A(("GRAY" "GOLD" "BLUE") ("SILK" "WOOL" "YARN")))
(is "⊂[2]2 3 4⍴'GRAYGOLDBLUESILKWOOLYARN'"
#2A(("GGB" "ROL" "ALU" "YDE") ("SWY" "IOA" "LOR" "KLN")))
(is "⊂[1]2 3 4⍴'GRAYGOLDBLUESILKWOOLYARN'"
#2A(("GS" "RI" "AL" "YK") ("GW" "OO" "LO" "DL") ("BY" "LA" "UR" "EN")))
(is "⊂[2 3]2 3 4⍴'GRAYGOLDBLUESILKWOOLYARN'"
#(#2A((#\G #\R #\A #\Y) (#\G #\O #\L #\D) (#\B #\L #\U #\E))
#2A((#\S #\I #\L #\K) (#\W #\O #\O #\L) (#\Y #\A #\R #\N))))
(is "⊂[1 3]2 3 4⍴'GRAYGOLDBLUESILKWOOLYARN'"
#(#2A((#\G #\R #\A #\Y) (#\S #\I #\L #\K))
#2A((#\G #\O #\L #\D) (#\W #\O #\O #\L))
#2A((#\B #\L #\U #\E) (#\Y #\A #\R #\N))))
(is "⊂[1 2]2 3 4⍴'GRAYGOLDBLUESILKWOOLYARN'"
#(#2A((#\G #\G #\B) (#\S #\W #\Y)) #2A((#\R #\O #\L) (#\I #\O #\A))
#2A((#\A #\L #\U) (#\L #\O #\R)) #2A((#\Y #\D #\E) (#\K #\L #\N))))
(is "{x←⊂[2] ⋄ x ⍵} 2 3 4⍴⍳9" #2A((#(1 5 9) #(2 6 1) #(3 7 2) #(4 8 3))
(#(4 8 3) #(5 9 4) #(6 1 5) #(7 2 6))))
(is "1⊂2" #(#(2)))
(is "1⊂5" #(#(5)))
(is "1⊂⍳5" #(#(1) #(2) #(3) #(4) #(5)))
(is "2⊂⍳5" #(#() #(1) #() #(2) #() #(3) #() #(4) #() #(5)))
(is "0 1 0 0 1 1 0 0 0⊂⍳9" #(#(2 3 4) #(5) #(6 7 8 9)))
(is "0 1 0 0 1 1 0 0⊂4 8⍴⍳9"
#(#2A((2 3 4) (1 2 3) (9 1 2) (8 9 1)) #2A((5) (4) (3) (2))
#2A((6 7 8) (5 6 7) (4 5 6) (3 4 5))))
(is "0 1 0 1⊂[1]4 8⍴⍳9"
#(#2A((9 1 2 3 4 5 6 7) (8 9 1 2 3 4 5 6)) #2A((7 8 9 1 2 3 4 5))))
(is "2 0 1 3 0 2 0 1⊂'abcdefg'" #(#() "ab" "c" #() #() "de" #() "fg" #()))
(is "0 0 2 0 1⊂'abcdefg'" #(#() "cd" "efg"))
(is "3⍴0 0 0 0⊂⍳3" #(#() #() #()))
(is "(0/⍳3 3)≡⊃0 0 0⊂⍳3 3" 1)
(is "⊃0 0 0⊂⍳3 3" #2A(() () ()))
(is "⊃⊃0 0 0⊂⍳3 3" #*00)))
(⊆ (has :titles ("Nest" "Partition"))
(ambivalent (λω (make-instance 'vader-partition :index-origin index-origin :base omega))
(λωα (make-instance 'vader-partition
:argument alpha :index-origin index-origin :base omega
:axis (or (first axes) :last))))
(meta (primary :axes axes :implicit-args (index-origin))
(monadic :inverse #'identity)
(dyadic :on-axis :last))
(tests (is " ⊆ ⍳3" #0A#(1 2 3))
(is " ⊆⊂⍳3" #0A#(1 2 3))
(is "⊃⊆⊂⍳3" #(1 2 3))
(is "⊆1 2 (1 2 3)" #(1 2 #(1 2 3)))
(is "⊆ 'hello'" #0A"hello")
(is "⊆⊂'hello'" #0A"hello")
(is "⊆'hello' 'how' 'are' 'you'" #("hello" "how" "are" "you"))
(is "2⊆⍳3" #(#(1 2 3)))
(is "1 1 0⊆5 6 0" #(#(5 6)))
(is "1 1 2 2 2 3 3 3 3⊆⍳9" #(#(1 2) #(3 4 5) #(6 7 8 9)))
(is "1 1 0 1⊆4 4 4⍴⍳9" #3A(((#(1 2) #(4)) (#(5 6) #(8)) (#(9 1) #(3)) (#(4 5) #(7)))
((#(8 9) #(2)) (#(3 4) #(6)) (#(7 8) #(1)) (#(2 3) #(5)))
((#(6 7) #(9)) (#(1 2) #(4)) (#(5 6) #(8)) (#(9 1) #(3)))
((#(4 5) #(7)) (#(8 9) #(2)) (#(3 4) #(6)) (#(7 8) #(1)))))
(is "1 1 0 1⊆[2]4 4 4⍴⍳9" #3A(((#(1 5) #(2 6) #(3 7) #(4 8)) (#(4) #(5) #(6) #(7)))
((#(8 3) #(9 4) #(1 5) #(2 6)) (#(2) #(3) #(4) #(5)))
((#(6 1) #(7 2) #(8 3) #(9 4)) (#(9) #(1) #(2) #(3)))
((#(4 8) #(5 9) #(6 1) #(7 2)) (#(7) #(8) #(9) #(1)))))))
(⊃ (has :titles ("Disclose" "Pick"))
(ambivalent (λω (make-instance 'vader-pick :base omega))
(λωα (make-instance 'vader-pick :base omega :argument alpha :index-origin index-origin)))
(meta (primary :implicit-args (index-origin))
(monadic :inverse (λωχ (if axes (error "Inverse [⊃ disclose] does not accept axis arguments.")
(make-instance 'vader-enclose :base omega :index-origin index-origin)))
:selective-assignment-compatible t)
(dyadic :selective-assignment-compatible t :selective-assignment-enclosing t
:selective-assignment-function :pick))
(tests (is "⊃3" 3)
(is "⊃⍳4" 1)
(is "⊃⊂⍳4" #(1 2 3 4))