totally_lazy 0.1.57 → 0.1.58
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/totally_lazy/enumerators.rb +6 -4
- data/lib/totally_lazy/numbers.rb +8 -0
- data/spec/totally_lazy/numbers_spec.rb +15 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzJmZGNkMjM1M2NhMGYwNjc0Y2UyZGQzYmMxOWQzODZjYmM0ZjE2MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzI1ZGNmNjRmY2JhNDBjNjMyMjg1MWNkNTkwNWI2MGIzYzI1OGFmNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODdlMzk3MDE3NTA2YjFkZjJlMWIzZjhhY2UxM2VjZTU0N2U0NjdiMDQwNjlm
|
10
|
+
OTI5OTU5MTVmMGRiMGM5MDJhMTQ3ZDdmOWFjMjAzMWEyOTljMGMxOWIxMzI2
|
11
|
+
MjA5NDZlZjI2NDE0NmE3NmMwNTJhZDM2N2Y0ODllMzUzZGM3MmQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MWJhMDFlZTU0ODY5MzBjMThlNzYzMDczOTA2MjYxMThjNWViODUxNWU2ODQw
|
14
|
+
MTg2MzVmOGM4ZTIzYWM1OWNlNzcwMzEyOGNhZWI2OWYyYWY2ZGI0ZTc5ZGIw
|
15
|
+
ZTgzODMzMzM1ZWRkN2I4NTBmNzk1YTUxNDgzNTQ4NWY2MDNlYjI=
|
@@ -73,11 +73,13 @@ module Enumerators
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def enumerate(fn, start)
|
76
|
-
current = start
|
77
76
|
Enumerator.new do |y|
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
current = start
|
78
|
+
loop do
|
79
|
+
result = current
|
80
|
+
current = fn.(current)
|
81
|
+
y << result
|
82
|
+
end
|
81
83
|
end.lazy
|
82
84
|
end
|
83
85
|
|
data/lib/totally_lazy/numbers.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe 'Numbers' do
|
4
|
+
it 'should support arbitrary multiply' do
|
5
|
+
expect(sequence(1, 2, 3, 4, 5).map(multiply(5))).to eq(sequence(5, 10, 15, 20, 25))
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should treat multiply as a monoid' do
|
9
|
+
expect(empty.reduce(multiply(5))).to eq(1)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should be able to get powers_of a number' do
|
13
|
+
expect(powers_of(3).take(10)).to eq(sequence(1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683))
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: totally_lazy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.58
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raymond Barlow
|
@@ -172,6 +172,7 @@ files:
|
|
172
172
|
- spec/totally_lazy/either_spec.rb
|
173
173
|
- spec/totally_lazy/functions_spec.rb
|
174
174
|
- spec/totally_lazy/maps_spec.rb
|
175
|
+
- spec/totally_lazy/numbers_spec.rb
|
175
176
|
- spec/totally_lazy/option_spec.rb
|
176
177
|
- spec/totally_lazy/predicates_spec.rb
|
177
178
|
- spec/totally_lazy/sequence_spec.rb
|