church 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
data/lib/church/utils.rb CHANGED
@@ -5,4 +5,13 @@ module Church::Utils
5
5
  ord > 64 && ord < 91 ? CHR[(ord - 78) % 26 + 65] :
6
6
  ord > 96 && ord < 123 ? CHR[(ord - 110) % 26 + 97] : chr
7
7
  }
8
+
9
+ COLLATZ = -> n {
10
+ c = [n]
11
+ (collatz_p = -> {
12
+ n = n % 2 == 0 ? n / 2 : n * 3 + 1
13
+ c << n
14
+ n == 1 ? c : collatz_p[]
15
+ })[]
16
+ }
8
17
  end
@@ -1,3 +1,3 @@
1
1
  module Church
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
data/spec/utils_spec.rb CHANGED
@@ -12,4 +12,19 @@ describe 'ROT13' do
12
12
  expect(ROT13['M']).to eq 'Z'
13
13
  expect(ROT13['Z']).to eq 'M'
14
14
  end
15
+
16
+ it "should not touch a non-alphabetical character" do
17
+ expect(ROT13['!']).to eq '!'
18
+ expect(ROT13[' ']).to eq ' '
19
+ end
20
+ end
21
+
22
+ describe 'COLLATZ' do
23
+ it "should return its arguments Collatz sequence as an array" do
24
+ expect(COLLATZ[10]).to eq [10, 5, 16, 8, 4, 2, 1]
25
+ end
26
+
27
+ it "should work on 194" do
28
+ expect(SIZE[COLLATZ[194]]).to be 120
29
+ end
15
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: church
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: