mf 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/{Guardfile.rb → Guardfile} +0 -0
- data/README.md +4 -1
- data/lib/mf/public_api.rb +74 -17
- data/lib/mf/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '04692a44951a504a8953c3613d7b0fd9a039acdf75a6f5fdfecc84d3ad582e8c'
|
4
|
+
data.tar.gz: dc2eb37ef5a9bfb7f1fafa2f936759d6cdc5f4cd1c43010065791224aebde2ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfd353621b03c3619eb584d9050f31b2b808d1fe6ec5ef634c674cf1c4e32297aab54dd2e57067bb0bf5189dff25b79f7dd2d37a91fd81004cb1309b2bb2b64d
|
7
|
+
data.tar.gz: 1d9f50437bb951b19b6bd6c12e559834004ca5f6e5fbaac963d30b702266ddf1b87a457e7c212441bab52d8e126f82cc0e19b8ae87fc90c25905c33fb7b1bd56
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/{Guardfile.rb → Guardfile}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Mf
|
2
2
|
|
3
|
-
|
3
|
+
Modifier functions. More of an experiment for now with syntactic sugar operators
|
4
4
|
after an idea occurred:
|
5
5
|
|
6
6
|
Can Ruby define `self` infix operators and `curry` / `proc`ify them?
|
@@ -70,6 +70,9 @@ numbers.map(&Mf | 3)
|
|
70
70
|
|
71
71
|
numbers.map(&Mf & 3)
|
72
72
|
#=> [1, 2, 3, 0, 1]
|
73
|
+
|
74
|
+
%w(foo bar baz).map(&Mf[0..1])
|
75
|
+
=> ["fo", "ba", "ba"]
|
73
76
|
```
|
74
77
|
|
75
78
|
## Installation
|
data/lib/mf/public_api.rb
CHANGED
@@ -1,28 +1,85 @@
|
|
1
1
|
module Mf
|
2
2
|
module PublicApi
|
3
3
|
# Math infix operators
|
4
|
-
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def
|
4
|
+
|
5
|
+
def +(b)
|
6
|
+
proc { |a| a + b }
|
7
|
+
end
|
8
|
+
|
9
|
+
def -(b)
|
10
|
+
proc { |a| a - b }
|
11
|
+
end
|
12
|
+
|
13
|
+
def *(b)
|
14
|
+
proc { |a| a * b }
|
15
|
+
end
|
16
|
+
|
17
|
+
def /(b)
|
18
|
+
proc { |a| a / b }
|
19
|
+
end
|
20
|
+
|
21
|
+
def %(b)
|
22
|
+
proc { |a| a % b }
|
23
|
+
end
|
24
|
+
|
25
|
+
def **(b)
|
26
|
+
proc { |a| a ** b }
|
27
|
+
end
|
10
28
|
|
11
29
|
# Comparators
|
12
|
-
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
def
|
30
|
+
|
31
|
+
def >(b)
|
32
|
+
proc { |a| a > b }
|
33
|
+
end
|
34
|
+
|
35
|
+
def >=(b)
|
36
|
+
proc { |a| a >= b }
|
37
|
+
end
|
38
|
+
|
39
|
+
def <(b)
|
40
|
+
proc { |a| a < b }
|
41
|
+
end
|
42
|
+
|
43
|
+
def <=(b)
|
44
|
+
proc { |a| a <= b }
|
45
|
+
end
|
46
|
+
|
47
|
+
def <=>(b)
|
48
|
+
proc { |a| a <=> b }
|
49
|
+
end
|
50
|
+
|
51
|
+
def ==(b)
|
52
|
+
proc { |a| a == b }
|
53
|
+
end
|
18
54
|
|
19
55
|
# Triple Equals black magic for pre-2.6
|
20
|
-
|
56
|
+
|
57
|
+
def ===(b)
|
58
|
+
proc { |a| b === a }
|
59
|
+
end
|
21
60
|
|
22
61
|
# Bit Operators
|
23
|
-
|
24
|
-
def
|
25
|
-
|
26
|
-
|
62
|
+
|
63
|
+
def |(b)
|
64
|
+
proc { |a| a | b }
|
65
|
+
end
|
66
|
+
|
67
|
+
def &(b)
|
68
|
+
proc { |a| a & b }
|
69
|
+
end
|
70
|
+
|
71
|
+
def >>(b)
|
72
|
+
proc { |a| a >> b }
|
73
|
+
end
|
74
|
+
|
75
|
+
def <<(b)
|
76
|
+
proc { |a| a << b }
|
77
|
+
end
|
78
|
+
|
79
|
+
# Bracket Accessors
|
80
|
+
|
81
|
+
def [](b)
|
82
|
+
proc { |a| a[b] }
|
83
|
+
end
|
27
84
|
end
|
28
85
|
end
|
data/lib/mf/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Weaver
|
@@ -93,7 +93,7 @@ files:
|
|
93
93
|
- CODE_OF_CONDUCT.md
|
94
94
|
- Gemfile
|
95
95
|
- Gemfile.lock
|
96
|
-
- Guardfile
|
96
|
+
- Guardfile
|
97
97
|
- LICENSE.txt
|
98
98
|
- README.md
|
99
99
|
- Rakefile
|