church 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/church/io.rb CHANGED
@@ -29,4 +29,12 @@ module Church
29
29
 
30
30
  # Joins the collection into a string on a specified delimiter
31
31
  JOIN = -> coll, delim { coll * delim }
32
+
33
+ # Converts its string argument to a number
34
+ TO_I = -> str {
35
+ (to_i = -> i {
36
+ i = i * 10 + ORD[str[0]] - ORD['0']
37
+ (str = str[1..-1]) == '' ? i : to_i[i]
38
+ })[0]
39
+ }
32
40
  end
data/lib/church/utils.rb CHANGED
@@ -6,6 +6,7 @@ module Church::Utils
6
6
  ord > 96 && ord < 123 ? CHR[(ord - 110) % 26 + 97] : chr
7
7
  }
8
8
 
9
+ # Returns its argument's Collatz sequence as an array
9
10
  COLLATZ = -> n {
10
11
  c = [n]
11
12
  (collatz_p = -> {
@@ -1,3 +1,3 @@
1
1
  module Church
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
data/spec/io_spec.rb CHANGED
@@ -29,3 +29,10 @@ describe 'JOIN' do
29
29
  expect(JOIN[[1, 2, 3], '']).to eq '123'
30
30
  end
31
31
  end
32
+
33
+ describe 'TO_I' do
34
+ it "should convert its argument to a number" do
35
+ expect(TO_I['0']).to be 0
36
+ expect(TO_I['12345']).to be 12345
37
+ end
38
+ 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.13
4
+ version: 0.0.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: