daitai 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4ef6ff2d48ef837e06b6c3ab0e191bf636a4276a
4
- data.tar.gz: 24bbdb9ac09c9141b5af75a224d622fae88cf632
2
+ SHA256:
3
+ metadata.gz: b580a7ada3ae9b6b21a4c8cc3aaa6768cbca06f267081dd2c53e8da0db8b82d0
4
+ data.tar.gz: 495f5ed0f52a58a53247fae9d2f41795b915b7f33b4d60a530f203bea681eb82
5
5
  SHA512:
6
- metadata.gz: 77c652dc02cf78efc39eb852119cb3c36d78d00cf1da4fc602cc11d002f97174098712ac99b21d15a48f742042eefe21e76405406b2729196172399e4bfacfa2
7
- data.tar.gz: 56c6ec334c3f9660ae6880e4cf5a57c95aeaafc6c7b3f73244166ffd1a2dee75f5992076adc25138e224ab55c3c0a61fff7d5222d627391cbe1f6203f3124f62
6
+ metadata.gz: 5f708096ff66b8c837fe24bc24b0a41b4373ca9bcc85c7280fdec9ffb4b8967a2161bfdddaa3354cea01ff5bcf103a156371b839a396dbc28df7e778f4c0d9ba
7
+ data.tar.gz: 3a7836b2adddc9ec27fa54261303996fe3f0999067bc8f6682123ae73983cc901d626c66643c8a369a08a13184a3395e8dfa01b4932daed1ae3b2a1146c8efdd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- daitai (0.1.4)
4
+ daitai (0.1.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -37,12 +37,16 @@ $ gem install daitai
37
37
  * [and](#and-definition)
38
38
  * [any](#any-definition)
39
39
  * [compose](#compose-definition)
40
+ * [concat](#concat-definition)
40
41
  * [divide](#divide-definition)
41
42
  * [filter](#filter-definition)
42
43
  * [head](#head-definition)
43
44
  * [init](#init-definition)
44
45
  * [last](#last-definition)
46
+ * [length](#length-definition)
45
47
  * [map](#map-definition)
48
+ * [max](#max-definition)
49
+ * [min](#min-definition)
46
50
  * [modulo](#modulo-definition)
47
51
  * [multiply](#multiply-definition)
48
52
  * [negate](#negate-definition)
@@ -51,6 +55,7 @@ $ gem install daitai
51
55
  * [pipe](#pipe-definition)
52
56
  * [product](#product-definition)
53
57
  * [reduce](#reduce-definition)
58
+ * [reverse](#reverse-definition)
54
59
  * [signum](#signum-definition)
55
60
  * [sort](#sort-definition)
56
61
  * [subtract](#subtract-definition)
@@ -142,6 +147,19 @@ f.(10) # => 144
142
147
 
143
148
  - - -
144
149
 
150
+ <h4 id='concat-definition'>
151
+ <code>concat :: [a] -> [a] -> [a]</code>
152
+ </h4>
153
+
154
+ Returns the result of concatenating provided lists or strings.
155
+
156
+ ```ruby
157
+ Daitai.concat.([1, 2], [3, 4]) # => [1, 2, 3, 4]
158
+ Daitai.concat.("Szcz", "ecin") # => "Szczecin"
159
+ ```
160
+
161
+ - - -
162
+
145
163
  <h4 id='divide-definition'>
146
164
  <code>divide :: a -> a -> a</code>
147
165
  </h4>
@@ -203,8 +221,21 @@ Daitai.init.("Ruby") # => "Rub"
203
221
  Returns the last element of a list.
204
222
 
205
223
  ```ruby
206
- Daitai.head.([1, 2, 3, 4]) # => 4
207
- Daitai.head.("Ruby") # => "y"
224
+ Daitai.last.([1, 2, 3, 4]) # => 4
225
+ Daitai.last.("Ruby") # => "y"
226
+ ```
227
+
228
+ - - -
229
+
230
+ <h4 id='length-definition'>
231
+ <code>length :: [a] -> Integer</code>
232
+ </h4>
233
+
234
+ Returns the length of a list.
235
+
236
+ ```ruby
237
+ Daitai.length.([1, 2, 3, 4]) # => 4
238
+ Daitai.length.("Ruby") # => 4
208
239
  ```
209
240
 
210
241
  - - -
@@ -225,6 +256,38 @@ increment.([1, 2, 3, 4]) # => [2, 3, 4, 5]
225
256
 
226
257
  - - -
227
258
 
259
+ <h4 id='max-definition'>
260
+ <code>max :: a -> a -> a</code>
261
+ </h4>
262
+
263
+ Returns the larger of two arguments.
264
+
265
+ ```ruby
266
+ Daitai.max.(6, 7) # => 7
267
+
268
+ non_negative = Daitai.max.(0)
269
+ non_negative.(-7) # => 0
270
+ non_negative.(11) # => 11
271
+ ```
272
+
273
+ - - -
274
+
275
+ <h4 id='min-definition'>
276
+ <code>min :: a -> a -> a</code>
277
+ </h4>
278
+
279
+ Returns the smaller of two arguments.
280
+
281
+ ```ruby
282
+ Daitai.min.(6, 7) # => 6
283
+
284
+ non_positive = Daitai.min.(0)
285
+ non_positive.(-7) # => -7
286
+ non_positive.(11) # => 0
287
+ ```
288
+
289
+ - - -
290
+
228
291
  <h4 id='modulo-definition'>
229
292
  <code>modulo :: a -> a -> a</code>
230
293
  </h4>
@@ -335,6 +398,19 @@ concat.(%w[l a m b d a]) # => "lambda"
335
398
 
336
399
  - - -
337
400
 
401
+ <h4 id='reverse-definition'>
402
+ <code>reverse :: [a] -> [a]</code>
403
+ </h4>
404
+
405
+ Returns the elements of a list in reverse order.
406
+
407
+ ```ruby
408
+ Daitai.reverse.([0, 5, 10, 15]) # => [15, 10, 5, 0]
409
+ Daitai.reverse.("raw desserts") # => "stressed war"
410
+ ```
411
+
412
+ - - -
413
+
338
414
  <h4 id='signum-definition'>
339
415
  <code>signum :: a -> a</code>
340
416
  </h4>
data/lib/daitai.rb CHANGED
@@ -9,12 +9,16 @@ module Daitai
9
9
  extend And
10
10
  extend Any
11
11
  extend Compose
12
+ extend Concat
12
13
  extend Divide
13
14
  extend Filter
14
15
  extend Head
15
16
  extend Init
16
17
  extend Last
18
+ extend Length
17
19
  extend Map
20
+ extend Max
21
+ extend Min
18
22
  extend Modulo
19
23
  extend Multiply
20
24
  extend Negate
@@ -23,6 +27,7 @@ module Daitai
23
27
  extend Pipe
24
28
  extend Product
25
29
  extend Reduce
30
+ extend Reverse
26
31
  extend Signum
27
32
  extend Sort
28
33
  extend Subtract
data/lib/daitai/abs.rb CHANGED
@@ -3,9 +3,7 @@
3
3
  module Daitai
4
4
  module Abs
5
5
  def abs
6
- lambda do |x|
7
- x < 0 ? -x : x
8
- end
6
+ ->(x) { x < 0 ? -x : x }
9
7
  end
10
8
  end
11
9
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Daitai
4
+ module Concat
5
+ def concat
6
+ lambda do |x, y|
7
+ case x
8
+ when String then string_concat(x, y)
9
+ else default_concat(x, y)
10
+ end
11
+ end.curry
12
+ end
13
+
14
+ private
15
+
16
+ def string_concat(x, y)
17
+ x + y
18
+ end
19
+
20
+ def default_concat(x, y)
21
+ x.concat(y)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Daitai
4
+ module Length
5
+ def length
6
+ ->(list) { list.length }
7
+ end
8
+ end
9
+ end
data/lib/daitai/max.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Daitai
4
+ module Max
5
+ def max
6
+ ->(a, b) { a > b ? a : b }.curry
7
+ end
8
+ end
9
+ end
data/lib/daitai/min.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Daitai
4
+ module Min
5
+ def min
6
+ ->(a, b) { a < b ? a : b }.curry
7
+ end
8
+ end
9
+ end
data/lib/daitai/negate.rb CHANGED
@@ -3,9 +3,7 @@
3
3
  module Daitai
4
4
  module Negate
5
5
  def negate
6
- lambda do |x|
7
- -x
8
- end
6
+ ->(x) { -x }
9
7
  end
10
8
  end
11
9
  end
data/lib/daitai/not.rb CHANGED
@@ -3,9 +3,7 @@
3
3
  module Daitai
4
4
  module Not
5
5
  def not
6
- lambda do |a|
7
- !a
8
- end
6
+ ->(a) { !a }
9
7
  end
10
8
  end
11
9
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Daitai
4
+ module Reverse
5
+ def reverse
6
+ ->(list) { list.reverse }
7
+ end
8
+ end
9
+ end
data/lib/daitai/signum.rb CHANGED
@@ -3,9 +3,7 @@
3
3
  module Daitai
4
4
  module Signum
5
5
  def signum
6
- lambda do |x|
7
- x <=> 0
8
- end
6
+ ->(x) { x <=> 0 }
9
7
  end
10
8
  end
11
9
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Daitai
4
- VERSION = '0.1.4'.freeze
4
+ VERSION = '0.1.5'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daitai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Walerian Sobczak
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-02 00:00:00.000000000 Z
11
+ date: 2018-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -93,12 +93,16 @@ files:
93
93
  - lib/daitai/and.rb
94
94
  - lib/daitai/any.rb
95
95
  - lib/daitai/compose.rb
96
+ - lib/daitai/concat.rb
96
97
  - lib/daitai/divide.rb
97
98
  - lib/daitai/filter.rb
98
99
  - lib/daitai/head.rb
99
100
  - lib/daitai/init.rb
100
101
  - lib/daitai/last.rb
102
+ - lib/daitai/length.rb
101
103
  - lib/daitai/map.rb
104
+ - lib/daitai/max.rb
105
+ - lib/daitai/min.rb
102
106
  - lib/daitai/modulo.rb
103
107
  - lib/daitai/multiply.rb
104
108
  - lib/daitai/negate.rb
@@ -107,6 +111,7 @@ files:
107
111
  - lib/daitai/pipe.rb
108
112
  - lib/daitai/product.rb
109
113
  - lib/daitai/reduce.rb
114
+ - lib/daitai/reverse.rb
110
115
  - lib/daitai/signum.rb
111
116
  - lib/daitai/sort.rb
112
117
  - lib/daitai/subtract.rb
@@ -133,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
138
  version: '0'
134
139
  requirements: []
135
140
  rubyforge_project:
136
- rubygems_version: 2.2.2
141
+ rubygems_version: 2.7.3
137
142
  signing_key:
138
143
  specification_version: 4
139
144
  summary: A functional library for Ruby.