-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.apln
29 lines (24 loc) · 1.14 KB
/
utils.apln
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
:Namespace utils
⍝ constants
ct_default←1E¯14 ⍝ ⎕CT values
dct_default←1E¯28
fr_dbl←645 ⍝ ⎕FR values
fr_decf←1287
io_default←1 ⍝ ⎕IO values
io_0←0
div_0←0 ⍝ ⎕DIV values
div_1←1
⍝ utility functions
shuffle←{⊂⍤?⍨∘≢⌷⍵} ⍝ completely Random shuffle
intertwine←{(⊂⍋∊⍳∘≢¨⍺ ⍵)⌷⍺⍪⍵} ⍝ perfectly intertwine two arrays
hashArray←1500⌶ ⍝ pre-hash array
stripToSameLen←{(⍺(⌊⍥≢)⍵)↑¨⍺ ⍵} ⍝ get two arrays to the length of the shorter array
numOrChar←{326(=-⍨2|⊢)⎕DR ⍵} ⍝ Type of ⍵ (¯1:mixed, 0:character, 1:numeric)
change0sto1←{1⊢+⊣×0=⊢} ⍝ Replacing zeroes in ⍵ with 1
⍝ Interpreter version information
isClassic←82=⎕dr''
width←{2×⎕SIZE '⍵'}⍬
isBigEndian←0=⊃11 ⎕DR 128
version←{⍎(2>+\⍵='.')/⍵}⊃1↓'.'⎕wg'APLVersion'
doSlowTests←((,'1')≡ 2 ⎕NQ #'GetEnvironment' 'DYALOG_QA_SLOW_TESTS')
:EndNamespace