unicode_math 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -55,6 +55,20 @@ You can raise to the powers of 0–9 as well as arbitrary numbers:
55
55
 
56
56
  5.× 5
57
57
 
58
+ ### Sigma and pi notations
59
+
60
+ You can sum up or multiply emlements of either an array or range:
61
+
62
+ Σ [1, 2, 3, 4]
63
+ Σ (1..10)
64
+ Π [1, 2, 3, 4]
65
+ Π (1..10)
66
+
67
+ ### Array as set
68
+
69
+ [2, 3, 5, 7].∩ [3, 5, 7, 9]
70
+ [2, 3, 5, 7].∪ [3, 5, 7, 9]
71
+
58
72
  ## Installation
59
73
 
60
74
  Add this line to your application's Gemfile:
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ module UnicodeMath
4
+ module Set
5
+ def self.included(base)
6
+ base.class_eval do
7
+ define_method('∩') do |set|
8
+ self & set
9
+ end
10
+
11
+ define_method('∪') do |set|
12
+ self | set
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ Array.send(:include, UnicodeMath::Set)
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ module UnicodeMath
4
+ module Sigma
5
+ def self.included(base)
6
+ base.class_eval do
7
+ define_method('Σ') do |enum|
8
+ enum.inject(:+)
9
+ end
10
+
11
+ define_method('Π') do |enum|
12
+ enum.inject(:*)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ Kernel.send(:include, UnicodeMath::Sigma)
20
+
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe UnicodeMath::Set do
6
+ before do
7
+ @primes = [2, 3, 5, 7]
8
+ @odd_nums = [3, 5, 7, 9]
9
+ end
10
+
11
+ it 'defines the intersection operator: ∩' do
12
+ intersection = @primes.∩ @odd_nums
13
+ expect(intersection).to eq([3, 5, 7])
14
+ end
15
+
16
+ it 'defines the union operator: ∪' do
17
+ union = @primes.∪ @odd_nums
18
+ expect(union).to eq([2, 3, 5, 7, 9])
19
+ end
20
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe UnicodeMath::Sigma do
6
+ it 'defines Σ to sum up elements of array' do
7
+ result = Σ [1, 2, 3, 4]
8
+ expect(result).to eq(10)
9
+ end
10
+
11
+ it 'defines Σ to sum up elements of range' do
12
+ result = Σ (1..10)
13
+ expect(result).to eq(55)
14
+ end
15
+
16
+ it 'defines Π to multiply elements of array' do
17
+ result = Π [1, 2, 3, 4]
18
+ expect(result).to eq(24)
19
+ end
20
+
21
+ it 'defines Π to multiply elements of range' do
22
+ result = Π (1..10)
23
+ expect(result).to eq(3628800)
24
+ end
25
+ end
data/unicode_math.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'unicode_math'
5
- gem.version = '1.1.0'
5
+ gem.version = '1.2.0'
6
6
 
7
7
  gem.author = 'Collective Idea'
8
8
  gem.email = 'info@collectiveidea.com'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicode_math
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-11 00:00:00.000000000 Z
12
+ date: 2012-10-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -62,6 +62,8 @@ files:
62
62
  - lib/unicode_math/fractions.rb
63
63
  - lib/unicode_math/multiplication.rb
64
64
  - lib/unicode_math/roots.rb
65
+ - lib/unicode_math/set.rb
66
+ - lib/unicode_math/sigma.rb
65
67
  - lib/unicode_math/trigonometry.rb
66
68
  - spec/spec_helper.rb
67
69
  - spec/support/random.rb
@@ -71,8 +73,9 @@ files:
71
73
  - spec/unicode_math/fractions_spec.rb
72
74
  - spec/unicode_math/multiplication_spec.rb
73
75
  - spec/unicode_math/root_spec.rb
76
+ - spec/unicode_math/set_spec.rb
77
+ - spec/unicode_math/sigma_spec.rb
74
78
  - spec/unicode_math/trigonometry_spec.rb
75
- - spec/unicode_math_spec.rb
76
79
  - unicode_math.gemspec
77
80
  homepage: https://github.com/collectiveidea/unicode_math
78
81
  licenses: []
@@ -88,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
91
  version: '0'
89
92
  segments:
90
93
  - 0
91
- hash: 3615466882464385091
94
+ hash: -2333945918950048942
92
95
  required_rubygems_version: !ruby/object:Gem::Requirement
93
96
  none: false
94
97
  requirements:
@@ -97,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
100
  version: '0'
98
101
  segments:
99
102
  - 0
100
- hash: 3615466882464385091
103
+ hash: -2333945918950048942
101
104
  requirements: []
102
105
  rubyforge_project:
103
106
  rubygems_version: 1.8.24
@@ -113,5 +116,6 @@ test_files:
113
116
  - spec/unicode_math/fractions_spec.rb
114
117
  - spec/unicode_math/multiplication_spec.rb
115
118
  - spec/unicode_math/root_spec.rb
119
+ - spec/unicode_math/set_spec.rb
120
+ - spec/unicode_math/sigma_spec.rb
116
121
  - spec/unicode_math/trigonometry_spec.rb
117
- - spec/unicode_math_spec.rb
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe UnicodeMath do
4
- it 'is awesome'
5
- end