daitai 0.1.3 → 0.1.4

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
2
  SHA1:
3
- metadata.gz: f12e1a03e40649b94f4c292d9f28c595b7085d92
4
- data.tar.gz: 55173f99bfbcc084684470cd8adfb7ef8c63a02f
3
+ metadata.gz: 4ef6ff2d48ef837e06b6c3ab0e191bf636a4276a
4
+ data.tar.gz: 24bbdb9ac09c9141b5af75a224d622fae88cf632
5
5
  SHA512:
6
- metadata.gz: 877c971038097f02e7d304a8407ff1fd6e91edc7ecf118d1e337ce3b82a536b662c6bc56a2b4c48d110b6105ad65d53551290c7d8742f74a5f5f513612a000d1
7
- data.tar.gz: 576431a89a934202e58ac1ba3f5ac2cae24c6cdaa7973126399aa43e54d628503907ffb7fd68cc59d58258a073addbd459826acbfebd41a96e602d8f167e4f3e
6
+ metadata.gz: 77c652dc02cf78efc39eb852119cb3c36d78d00cf1da4fc602cc11d002f97174098712ac99b21d15a48f742042eefe21e76405406b2729196172399e4bfacfa2
7
+ data.tar.gz: 56c6ec334c3f9660ae6880e4cf5a57c95aeaafc6c7b3f73244166ffd1a2dee75f5992076adc25138e224ab55c3c0a61fff7d5222d627391cbe1f6203f3124f62
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- daitai (0.1.3)
4
+ daitai (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -39,6 +39,9 @@ $ gem install daitai
39
39
  * [compose](#compose-definition)
40
40
  * [divide](#divide-definition)
41
41
  * [filter](#filter-definition)
42
+ * [head](#head-definition)
43
+ * [init](#init-definition)
44
+ * [last](#last-definition)
42
45
  * [map](#map-definition)
43
46
  * [modulo](#modulo-definition)
44
47
  * [multiply](#multiply-definition)
@@ -52,6 +55,7 @@ $ gem install daitai
52
55
  * [sort](#sort-definition)
53
56
  * [subtract](#subtract-definition)
54
57
  * [sum](#sum-definition)
58
+ * [tail](#tail-definition)
55
59
 
56
60
  - - -
57
61
 
@@ -166,6 +170,45 @@ only_even.([1, 2, 3, 4]) # => [2, 4]
166
170
 
167
171
  - - -
168
172
 
173
+ <h4 id='head-definition'>
174
+ <code>head :: [a] -> a</code>
175
+ </h4>
176
+
177
+ Returns the first element of a list.
178
+
179
+ ```ruby
180
+ Daitai.head.([1, 2, 3, 4]) # => 1
181
+ Daitai.head.("Ruby") # => "R"
182
+ ```
183
+
184
+ - - -
185
+
186
+ <h4 id='init-definition'>
187
+ <code>init :: [a] -> [a]</code>
188
+ </h4>
189
+
190
+ Returns all the elements of a list except the last one.
191
+
192
+ ```ruby
193
+ Daitai.init.([1, 2, 3, 4]) # => [1, 2, 3]
194
+ Daitai.init.("Ruby") # => "Rub"
195
+ ```
196
+
197
+ - - -
198
+
199
+ <h4 id='last-definition'>
200
+ <code>last :: [a] -> a</code>
201
+ </h4>
202
+
203
+ Returns the last element of a list.
204
+
205
+ ```ruby
206
+ Daitai.head.([1, 2, 3, 4]) # => 4
207
+ Daitai.head.("Ruby") # => "y"
208
+ ```
209
+
210
+ - - -
211
+
169
212
  <h4 id='map-definition'>
170
213
  <code>map :: (a -> b) -> [a] -> [b]</code>
171
214
  </h4>
@@ -346,6 +389,19 @@ Daitai.sum.([1, 2, 3, 4]) # => 10
346
389
 
347
390
  - - -
348
391
 
392
+ <h4 id='tail-definition'>
393
+ <code>tail :: [a] -> [a]</code>
394
+ </h4>
395
+
396
+ Returns all the elements of a list except the first one.
397
+
398
+ ```ruby
399
+ Daitai.tail.([1, 2, 3, 4]) # => [2, 3, 4]
400
+ Daitai.tail.("Ruby") # => "uby"
401
+ ```
402
+
403
+ - - -
404
+
349
405
  ## Development
350
406
 
351
407
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/daitai.rb CHANGED
@@ -11,6 +11,9 @@ module Daitai
11
11
  extend Compose
12
12
  extend Divide
13
13
  extend Filter
14
+ extend Head
15
+ extend Init
16
+ extend Last
14
17
  extend Map
15
18
  extend Modulo
16
19
  extend Multiply
@@ -24,4 +27,5 @@ module Daitai
24
27
  extend Sort
25
28
  extend Subtract
26
29
  extend Sum
30
+ extend Tail
27
31
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Daitai
4
+ module Head
5
+ def head
6
+ ->(list) { list[0] }
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Daitai
4
+ module Init
5
+ def init
6
+ ->(list) { list[0..-2] }
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Daitai
4
+ module Last
5
+ def last
6
+ ->(list) { list[-1] }
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Daitai
4
+ module Tail
5
+ def tail
6
+ ->(list) { list[1..-1] }
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Daitai
4
- VERSION = '0.1.3'.freeze
4
+ VERSION = '0.1.4'.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.3
4
+ version: 0.1.4
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-01 00:00:00.000000000 Z
11
+ date: 2018-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -95,6 +95,9 @@ files:
95
95
  - lib/daitai/compose.rb
96
96
  - lib/daitai/divide.rb
97
97
  - lib/daitai/filter.rb
98
+ - lib/daitai/head.rb
99
+ - lib/daitai/init.rb
100
+ - lib/daitai/last.rb
98
101
  - lib/daitai/map.rb
99
102
  - lib/daitai/modulo.rb
100
103
  - lib/daitai/multiply.rb
@@ -108,6 +111,7 @@ files:
108
111
  - lib/daitai/sort.rb
109
112
  - lib/daitai/subtract.rb
110
113
  - lib/daitai/sum.rb
114
+ - lib/daitai/tail.rb
111
115
  - lib/daitai/version.rb
112
116
  homepage: https://github.com/walerian777/daitai
113
117
  licenses: