daitai 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +109 -1
- data/lib/daitai.rb +9 -12
- data/lib/daitai/abs.rb +9 -0
- data/lib/daitai/add.rb +9 -0
- data/lib/daitai/divide.rb +9 -0
- data/lib/daitai/modulo.rb +9 -0
- data/lib/daitai/multiply.rb +9 -0
- data/lib/daitai/negate.rb +9 -0
- data/lib/daitai/signum.rb +9 -0
- data/lib/daitai/subtract.rb +9 -0
- data/lib/daitai/version.rb +1 -1
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff5f9a0398ddd5b9986a5b49e7e4f24d4bf2bd91956c8412ec30248c202e4ddc
|
4
|
+
data.tar.gz: f04937930985840d55fa23360e40718c6925ca864b55a7e248e3e84ec585ee1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9582ec942bba4201b0d6d20d94956dd0653fa48576629cef90f96296466067f860499ffdde347827835a1e87b0b8fc0872c26592c85eb28f29263646fdd153ce
|
7
|
+
data.tar.gz: 93dc0089b5777f2bc1b8fd5387178e2a96df629b496c5d91696fdc43c232633ea20bdaa30cbb4524fd06b762e7c025a718b73e5948f6fea55b959c97aa267630
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -31,17 +31,50 @@ $ gem install daitai
|
|
31
31
|
```
|
32
32
|
|
33
33
|
## Documentation
|
34
|
+
* [abs](#abs-definition)
|
35
|
+
* [add](#add-definition)
|
34
36
|
* [all](#all-definition)
|
35
37
|
* [and](#and-definition)
|
36
38
|
* [any](#any-definition)
|
37
39
|
* [compose](#compose-definition)
|
40
|
+
* [divide](#divide-definition)
|
38
41
|
* [filter](#filter-definition)
|
39
42
|
* [map](#map-definition)
|
43
|
+
* [modulo](#modulo-definition)
|
44
|
+
* [multiply](#multiply-definition)
|
45
|
+
* [negate](#negate-definition)
|
40
46
|
* [not](#not-definition)
|
41
47
|
* [or](#or-definition)
|
42
48
|
* [pipe](#pipe-definition)
|
43
49
|
* [reduce](#reduce-definition)
|
50
|
+
* [signum](#signum-definition)
|
44
51
|
* [sort](#sort-definition)
|
52
|
+
* [subtract](#subtract-definition)
|
53
|
+
|
54
|
+
- - -
|
55
|
+
|
56
|
+
<h4 id='abs-definition'>
|
57
|
+
<code>abs :: a -> a</code>
|
58
|
+
</h4>
|
59
|
+
|
60
|
+
Returns the absolute value of an argument.
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
Daitai.abs.(11) # => 11
|
64
|
+
Daitai.abs.(-8) # => 8
|
65
|
+
```
|
66
|
+
|
67
|
+
- - -
|
68
|
+
|
69
|
+
<h4 id='add-definition'>
|
70
|
+
<code>add :: a -> a -> a</code>
|
71
|
+
</h4>
|
72
|
+
|
73
|
+
Calculates the sum of two arguments.
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
Daitai.add.(3, 4) # => 7
|
77
|
+
```
|
45
78
|
|
46
79
|
- - -
|
47
80
|
|
@@ -103,6 +136,18 @@ f.(10) # => 144
|
|
103
136
|
|
104
137
|
- - -
|
105
138
|
|
139
|
+
<h4 id='divide-definition'>
|
140
|
+
<code>divide :: a -> a -> a</code>
|
141
|
+
</h4>
|
142
|
+
|
143
|
+
Calculates the quotient of two arguments.
|
144
|
+
|
145
|
+
```ruby
|
146
|
+
Daitai.divide.(18, 6) # => 3
|
147
|
+
```
|
148
|
+
|
149
|
+
- - -
|
150
|
+
|
106
151
|
<h4 id='filter-definition'>
|
107
152
|
<code>filter :: (a -> Bool) -> [a] -> [a]</code>
|
108
153
|
</h4>
|
@@ -110,7 +155,7 @@ f.(10) # => 144
|
|
110
155
|
Returns a list of all elements that satisfy the predicate.
|
111
156
|
|
112
157
|
```ruby
|
113
|
-
greater_than_two = ->
|
158
|
+
greater_than_two = ->(x) { x > 2 }
|
114
159
|
Daitai.filter.(greater_than_two, [1, 2, 3, 4]) # => [3, 4]
|
115
160
|
```
|
116
161
|
|
@@ -129,6 +174,43 @@ Daitai.map.(triple, [1, 2, 3, 4]) # => [3, 6, 9, 12]
|
|
129
174
|
|
130
175
|
- - -
|
131
176
|
|
177
|
+
<h4 id='modulo-definition'>
|
178
|
+
<code>modulo :: a -> a -> a</code>
|
179
|
+
</h4>
|
180
|
+
|
181
|
+
Calculates the remainder after division of two arguments.
|
182
|
+
|
183
|
+
```ruby
|
184
|
+
Daitai.modulo.(18, 7) # => 4
|
185
|
+
```
|
186
|
+
|
187
|
+
- - -
|
188
|
+
|
189
|
+
<h4 id='multiply-definition'>
|
190
|
+
<code>multiply :: a -> a -> a</code>
|
191
|
+
</h4>
|
192
|
+
|
193
|
+
Calculates the product of two arguments.
|
194
|
+
|
195
|
+
```ruby
|
196
|
+
Daitai.multiply.(4, 3) # => 12
|
197
|
+
```
|
198
|
+
|
199
|
+
- - -
|
200
|
+
|
201
|
+
<h4 id='negate-definition'>
|
202
|
+
<code>negate :: Bool -> Bool</code>
|
203
|
+
</h4>
|
204
|
+
|
205
|
+
Unary negation - returns a negated value of the argument.
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
Daitai.negate.(11) # => -11
|
209
|
+
Daitai.negate.(-8) # => 8
|
210
|
+
```
|
211
|
+
|
212
|
+
- - -
|
213
|
+
|
132
214
|
<h4 id='not-definition'>
|
133
215
|
<code>not :: Bool -> Bool</code>
|
134
216
|
</h4>
|
@@ -187,6 +269,20 @@ Daitai.reduce.(sum, 0, [1, 2, 3, 4]) # => 10
|
|
187
269
|
|
188
270
|
- - -
|
189
271
|
|
272
|
+
<h4 id='signum-definition'>
|
273
|
+
<code>signum :: a -> a</code>
|
274
|
+
</h4>
|
275
|
+
|
276
|
+
Extracts the sign of an argument.
|
277
|
+
|
278
|
+
```ruby
|
279
|
+
Daitai.signum.(11) # => 1
|
280
|
+
Daitai.signum.(0) # => 0
|
281
|
+
Daitai.signum.(-8) # => -1
|
282
|
+
```
|
283
|
+
|
284
|
+
- - -
|
285
|
+
|
190
286
|
<h4 id='sort-definition'>
|
191
287
|
<code>sort :: (a -> a -> Number) -> [a] -> [a]</code>
|
192
288
|
</h4>
|
@@ -200,6 +296,18 @@ Daitai.sort.(diff, [2, 1, 4, 3]) # => [1, 2, 3, 4]
|
|
200
296
|
|
201
297
|
- - -
|
202
298
|
|
299
|
+
<h4 id='subtract-definition'>
|
300
|
+
<code>subtract :: a -> a -> a</code>
|
301
|
+
</h4>
|
302
|
+
|
303
|
+
Calculates the differce of two arguments.
|
304
|
+
|
305
|
+
```ruby
|
306
|
+
Daitai.subtract.(9, 4) # => 5
|
307
|
+
```
|
308
|
+
|
309
|
+
- - -
|
310
|
+
|
203
311
|
## Development
|
204
312
|
|
205
313
|
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
@@ -1,26 +1,23 @@
|
|
1
|
-
require
|
2
|
-
require 'daitai/and'
|
3
|
-
require 'daitai/any'
|
4
|
-
require 'daitai/compose'
|
5
|
-
require 'daitai/filter'
|
6
|
-
require 'daitai/map'
|
7
|
-
require 'daitai/not'
|
8
|
-
require 'daitai/or'
|
9
|
-
require 'daitai/pipe'
|
10
|
-
require 'daitai/reduce'
|
11
|
-
require 'daitai/sort'
|
12
|
-
require 'daitai/version'
|
1
|
+
Dir["#{__dir__}/daitai/*"].each { |file| require file }
|
13
2
|
|
14
3
|
module Daitai
|
4
|
+
extend Abs
|
5
|
+
extend Add
|
15
6
|
extend All
|
16
7
|
extend And
|
17
8
|
extend Any
|
18
9
|
extend Compose
|
10
|
+
extend Divide
|
19
11
|
extend Filter
|
20
12
|
extend Map
|
13
|
+
extend Modulo
|
14
|
+
extend Multiply
|
15
|
+
extend Negate
|
21
16
|
extend Not
|
22
17
|
extend Or
|
23
18
|
extend Pipe
|
24
19
|
extend Reduce
|
20
|
+
extend Signum
|
25
21
|
extend Sort
|
22
|
+
extend Subtract
|
26
23
|
end
|
data/lib/daitai/abs.rb
ADDED
data/lib/daitai/add.rb
ADDED
data/lib/daitai/version.rb
CHANGED
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
|
+
version: 0.1.2
|
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-02-
|
11
|
+
date: 2018-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -87,17 +87,25 @@ files:
|
|
87
87
|
- bin/setup
|
88
88
|
- daitai.gemspec
|
89
89
|
- lib/daitai.rb
|
90
|
+
- lib/daitai/abs.rb
|
91
|
+
- lib/daitai/add.rb
|
90
92
|
- lib/daitai/all.rb
|
91
93
|
- lib/daitai/and.rb
|
92
94
|
- lib/daitai/any.rb
|
93
95
|
- lib/daitai/compose.rb
|
96
|
+
- lib/daitai/divide.rb
|
94
97
|
- lib/daitai/filter.rb
|
95
98
|
- lib/daitai/map.rb
|
99
|
+
- lib/daitai/modulo.rb
|
100
|
+
- lib/daitai/multiply.rb
|
101
|
+
- lib/daitai/negate.rb
|
96
102
|
- lib/daitai/not.rb
|
97
103
|
- lib/daitai/or.rb
|
98
104
|
- lib/daitai/pipe.rb
|
99
105
|
- lib/daitai/reduce.rb
|
106
|
+
- lib/daitai/signum.rb
|
100
107
|
- lib/daitai/sort.rb
|
108
|
+
- lib/daitai/subtract.rb
|
101
109
|
- lib/daitai/version.rb
|
102
110
|
homepage: https://github.com/walerian777/daitai
|
103
111
|
licenses:
|