unicode_math 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -3
- data/Rakefile +0 -1
- data/lib/unicode_math/set.rb +22 -0
- data/lib/unicode_math/version.rb +1 -1
- data/spec/unicode_math/set_spec.rb +56 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2657e99df17e5ea1fcc6cd5b017e7bc02ec7536d
|
4
|
+
data.tar.gz: bc05e23a37690227f30789429f6162b61611eae0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d23edaacecb607146b0f04b7b6354634cfa1ca974769f36880b4e47fc467363ea7e80c577a3bba5bdfd9958a9d369fb0cfea13fb3e5b29f8ddc1c3746d1c0308
|
7
|
+
data.tar.gz: 915672527c6566360d354c71961bcb7033f5db2d7dfd769793c9a92bca0a2917271681b36bcc6b32f8cb1036e1498e7c77cc8b67b76e120d638fad88ef73e8b4
|
data/README.md
CHANGED
@@ -80,9 +80,14 @@ You can sum up or multiply emlements of either an array or range:
|
|
80
80
|
|
81
81
|
### Array as set
|
82
82
|
|
83
|
-
[2, 3, 5, 7].∩ [3, 5, 7, 9]
|
84
|
-
[2, 3, 5, 7].∪ [3, 5, 7, 9]
|
85
|
-
|
83
|
+
[2, 3, 5, 7].∩ [3, 5, 7, 9] # Intersection
|
84
|
+
[2, 3, 5, 7].∪ [3, 5, 7, 9] # Union
|
85
|
+
[2, 3, 5, 7].⊂ [3, 5, 7, 9] # Subset of
|
86
|
+
[2, 3, 5, 7].⊃ [3, 5, 7, 9] # Superset of
|
87
|
+
[2, 3, 5, 7].∈ [3, 5, 7, 9] # Belongs to
|
88
|
+
[2, 3, 5, 7].∉ [3, 5, 7, 9] # Does not belong to
|
89
|
+
[2, 3, 5, 7].∅ # Empty set
|
90
|
+
|
86
91
|
### Factorial
|
87
92
|
|
88
93
|
2.!
|
data/Rakefile
CHANGED
data/lib/unicode_math/set.rb
CHANGED
@@ -11,9 +11,31 @@ module UnicodeMath
|
|
11
11
|
define_method('∪') do |set|
|
12
12
|
self | set
|
13
13
|
end
|
14
|
+
|
15
|
+
define_method('⊂') do |set|
|
16
|
+
((set.∩ self) == self)
|
17
|
+
end
|
18
|
+
|
19
|
+
define_method('⊃') do |set|
|
20
|
+
((self.∩ set) == set)
|
21
|
+
end
|
22
|
+
|
23
|
+
define_method('∈') do |set|
|
24
|
+
(self.∩ set) == self
|
25
|
+
end
|
26
|
+
|
27
|
+
define_method('∉') do |set|
|
28
|
+
!((self.∩ set) == self)
|
29
|
+
end
|
30
|
+
|
31
|
+
define_method('∅') do
|
32
|
+
self.empty?
|
33
|
+
end
|
34
|
+
|
14
35
|
end
|
15
36
|
end
|
16
37
|
end
|
17
38
|
end
|
18
39
|
|
19
40
|
Array.send(:include, UnicodeMath::Set)
|
41
|
+
|
data/lib/unicode_math/version.rb
CHANGED
@@ -6,6 +6,8 @@ describe UnicodeMath::Set do
|
|
6
6
|
before do
|
7
7
|
@primes = [2, 3, 5, 7]
|
8
8
|
@odd_nums = [3, 5, 7, 9]
|
9
|
+
@superset = [1,2,3,4,5]
|
10
|
+
@subset = [3,5]
|
9
11
|
end
|
10
12
|
|
11
13
|
it 'defines the intersection operator: ∩' do
|
@@ -17,4 +19,58 @@ describe UnicodeMath::Set do
|
|
17
19
|
union = @primes.∪ @odd_nums
|
18
20
|
expect(union).to eq([2, 3, 5, 7, 9])
|
19
21
|
end
|
22
|
+
|
23
|
+
it 'defines subset A ⊂ B : true' do
|
24
|
+
subset = @subset.⊂ @superset
|
25
|
+
expect(subset).to eq(true)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'defines subset A ⊂ B : false' do
|
29
|
+
subset = @superset.⊂ @subset
|
30
|
+
expect(subset).to eq(false)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'defines superset A ⊃ B : false' do
|
34
|
+
subset = @subset.⊃ @superset
|
35
|
+
expect(subset).to eq(false)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'defines superset A ⊃ B : true' do
|
39
|
+
subset = @superset.⊃ @subset
|
40
|
+
expect(subset).to eq(true)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'defines A belongs to B, A ∈ B : false' do
|
44
|
+
belongs_to = @superset.∈ @subset
|
45
|
+
expect(belongs_to).to eq(false)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'defines A belongs to B, A ∈ B : true' do
|
49
|
+
belongs_to = @subset.∈ @superset
|
50
|
+
expect(belongs_to).to eq(true)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'defines A does not belong to B, A ∉ B : false' do
|
54
|
+
not_belongs_to = @subset.∉ @superset
|
55
|
+
#Does @subset does not belong to @primes ?
|
56
|
+
#True if it doesn't belong
|
57
|
+
expect(not_belongs_to).to eq(false)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'defines A does not belong to B, A ∉ B : true' do
|
61
|
+
not_belongs_to = @superset.∉ @subset
|
62
|
+
expect(not_belongs_to).to eq(true)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'defines A is empty' do
|
66
|
+
empty = @primes.∅
|
67
|
+
expect(empty).to eq(false)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'defines A is empty' do
|
71
|
+
empty = [].∅
|
72
|
+
expect(empty).to eq(true)
|
73
|
+
end
|
74
|
+
|
20
75
|
end
|
76
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unicode_math
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Collective Idea
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|