szczupac 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/szczupac/version.rb +1 -1
- data/lib/szczupac.rb +33 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 225c244bf3dbd3d7776978d61ac21989095f83421916b86c5942e37512809fec
|
4
|
+
data.tar.gz: cbf4f2f48fee666b10e61df3569130348d10ba6354bd3ba8aa5d595ab3097a06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a076ef2747de634e25eb55e71b7f8c78b5a5f7aed47e74764c323c7874dc3da5ce3debae3b1ff09c001fd56f765516dafac5a365aa09a6a113e79e043267ec02
|
7
|
+
data.tar.gz: 27e60b2d99adf4367c143f8e0cdfbe01887295a659dfc810f6131c0edc3bfb58fc4113f6ebb99f9302952c6f2bfb37d51c4b863155a8babfce89982b6f22396f
|
data/lib/szczupac/version.rb
CHANGED
data/lib/szczupac.rb
CHANGED
@@ -5,20 +5,41 @@ require_relative "szczupac/version"
|
|
5
5
|
module Szczupac
|
6
6
|
extend self
|
7
7
|
|
8
|
-
def
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
def axis(name, values)
|
9
|
+
values.map { |v| { name => v } }
|
10
|
+
end
|
11
|
+
|
12
|
+
def generate(*axes)
|
13
|
+
order = axes.flat_map { |a| a.flat_map(&:keys) }.uniq
|
14
|
+
|
15
|
+
axes
|
16
|
+
.flat_map do |axis|
|
17
|
+
rest = axes - [axis]
|
18
|
+
first_options = rest.map(&:first)
|
19
|
+
axis
|
20
|
+
.product([first_options.reduce(&:merge)])
|
21
|
+
.map { |product| product.reduce(&:merge) }
|
22
|
+
.map { |product| product.sort_by { |k, _| order.index(k) }.to_h }
|
23
|
+
end
|
24
|
+
.uniq
|
25
|
+
end
|
26
|
+
|
27
|
+
def permutation(*axes)
|
28
|
+
order = axes.flat_map { |a| a.map(&:keys) }.uniq
|
29
|
+
|
30
|
+
axes
|
31
|
+
.flat_map do |axis|
|
32
|
+
rest = axes - [axis]
|
33
|
+
axis
|
34
|
+
.product(*rest)
|
35
|
+
.map { |product| product.reduce(&:merge) }
|
36
|
+
.map { |product| product.sort_by { |k, _| order.index(k) }.to_h }
|
20
37
|
end
|
21
38
|
.uniq
|
22
39
|
end
|
40
|
+
|
41
|
+
def call(**named_lanes)
|
42
|
+
generate(*named_lanes.map { |name, values| axis(name, values) })
|
43
|
+
end
|
23
44
|
alias [] call
|
24
45
|
end
|