-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.apl
More file actions
47 lines (40 loc) · 1.22 KB
/
test.apl
File metadata and controls
47 lines (40 loc) · 1.22 KB
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
]COLOR OFF
DISP←{8⎕CR ⍵}
func←'(r⍨¨⍳∘.+(0J1×⍳))'
WHERE←{(,⍵)⌿,⍳⍴⍵}
∇R←K nest S
pairedArguments← (1-⍨K),¨S
R← {(⊂⍣(↑⍵))⊃1↓⍵}¨pairedArguments
∇
∇R←arrow F
segments← +\ '()'∊⍨F
nestingKey← {⍵/⍨1,2≢⌿⍵} +\(F∊'(') - (F∊')')
segdFWithoutZeros← 1↓¨ (0≠nestingKey)/segments⊂F
nestingKey←(0≠nestingKey)/nestingKey
segmented← ⊃,/nestingKey nest segdFWithoutZeros
R←segmented
∇
∇R←A (F AT G) W
bitmask← W∊W[G]
data←W
newVals← A F bitmask/data
(bitmask/data)← newVals
R←data
∇
∇R←(F ATB G) W
bitmask← W∊W[G]
data←W
newVals← F bitmask/data
(bitmask/data)← newVals
R←data
∇
x←⍳⍴func
dyadicOperatorKey← func∊'∘.⍤⍣@⍥J'
jotKey← dyadicOperatorKey∧¯1⌽func∊'∘'
dyadicOperatorKey←dyadicOperatorKey-1⌽jotKey ⍝ remove jots that are next to dots for outer product
processedKey← dyadicOperatorKey + 2ׯ1⌽dyadicOperatorKey
dyadicProcessedFunc←func⊂⍨x-processedKey
monadicOperatorKey← {+/⍵∊'¨⍨/⌿\⍀'}¨dyadicProcessedFunc
DISP monadicOperatorKey
DISP (0 1 1 0 0){0~⍨¨,/⍉(~⍺)/⍵,[1]1⌽1↓[1]⍺⊖⍵,[0.5]0}'abc' 'def' 'ghi' 'hij' 'klm'
)OFF