Skip to content

Commit

Permalink
mv util functions to different namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
sloorush committed Feb 5, 2024
1 parent 94b0681 commit 245950d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tests/unique.apln
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
:Namespace unique
Assert←#.unittest.Assert
⍝ util functions
shuffle←#.utils.shuffle
intertwine←#.utils.intertwine
hashArray←#.utils.hashArray

⍝ modelUnion←{⍺,(∧/⍺≢¨⍵)/⍵} ⍝ model function for union (X∪Y) (used to model unique)
model←{0=≢⍵:⍵ ⋄ ↑,⊃{⍺,(∧/⍺≢¨⍵)/⍵}⍨/⌽⊂¨⊂⍤¯1⊢⍵} ⍝ model function for unique

⍝ util functions
shuffle←{⊂⍤?⍨∘≢⌷⍵} ⍝ completely Random shuffle
intertwine←{(⊂⍋∊⍳∘≢¨⍺ ⍵)⌷⍺⍪⍵} ⍝ perfectly intertwine two arrays
hashArray←1500⌶

∇ tRes←tData RunVariations exp ;actualR;actualRE;expectedR;expectedRE;ele;rarg;tID;tCmt;shape;actualRS;shapeW0;actualRSW0;expectedRS;expectedRSW0
(expectedR rarg)←exp
(tID tCmt)←tData
Expand Down
5 changes: 5 additions & 0 deletions utils.apln
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:Namespace utils
shuffle←{⊂⍤?⍨∘≢⌷⍵} ⍝ completely Random shuffle
intertwine←{(⊂⍋∊⍳∘≢¨⍺ ⍵)⌷⍺⍪⍵} ⍝ perfectly intertwine two arrays
hashArray←1500⌶ ⍝ pre-hash array
:EndNamespace

0 comments on commit 245950d

Please sign in to comment.