lambdas 0.0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby-version +1 -0
- data/README.md +6 -1
- data/lib/lambdas.rb +15 -9
- data/lib/lambdas/version.rb +1 -1
- data/spec/lambdas_spec.rb +13 -5
- metadata +5 -3
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3-p374
|
data/README.md
CHANGED
@@ -18,7 +18,12 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
TODO: Write usage instructions here (coming soon)
|
21
|
+
TODO: Write usage instructions here (coming soon....)
|
22
|
+
|
23
|
+
```(ruby)
|
24
|
+
L.value('a').call #=> 'a'
|
25
|
+
L.i.call(123) #=> 123
|
26
|
+
````
|
22
27
|
|
23
28
|
## Contributing
|
24
29
|
|
data/lib/lambdas.rb
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
module Lambdas
|
2
2
|
extend self
|
3
|
-
def
|
4
|
-
|
3
|
+
def true
|
4
|
+
value(true)
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
8
|
-
|
7
|
+
def false
|
8
|
+
value(false)
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def nil
|
12
|
+
value(nil)
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def noop
|
16
|
+
lambda {|*args| }
|
17
|
+
end
|
18
|
+
|
19
|
+
def value(val)
|
16
20
|
lambda { val }
|
17
21
|
end
|
18
22
|
|
19
|
-
def
|
23
|
+
def identity
|
20
24
|
lambda {|a| a}
|
21
25
|
end
|
26
|
+
alias_method :i, :identity
|
22
27
|
|
23
|
-
def
|
28
|
+
def y
|
24
29
|
lambda { |f| f.call(f) }.call(
|
25
30
|
lambda do |g|
|
26
31
|
yield(lambda { |*n| g.call(g).call(*n) })
|
27
32
|
end)
|
28
33
|
end
|
29
34
|
end
|
35
|
+
L = Lambdas
|
data/lib/lambdas/version.rb
CHANGED
data/spec/lambdas_spec.rb
CHANGED
@@ -2,22 +2,30 @@ require 'lambdas'
|
|
2
2
|
|
3
3
|
describe "Included lambas" do
|
4
4
|
it "includes a true lambda" do
|
5
|
-
|
5
|
+
L.true.call.should be_true
|
6
6
|
end
|
7
7
|
|
8
8
|
it "includes a false lambda" do
|
9
|
-
|
9
|
+
L.false.call.should be_false
|
10
10
|
end
|
11
11
|
|
12
12
|
it "includes a nil lambda" do
|
13
|
-
|
13
|
+
L.nil.call.should be_nil
|
14
14
|
end
|
15
15
|
|
16
16
|
it "includes a value lambda" do
|
17
|
-
|
17
|
+
L.value(1).call.should eq 1
|
18
18
|
end
|
19
19
|
|
20
20
|
it "includes an identity lambda" do
|
21
|
-
|
21
|
+
L.identity.call(1).should eq 1
|
22
|
+
end
|
23
|
+
|
24
|
+
it "includes an identity lambda aliased to i" do
|
25
|
+
L.i.call(1).should eq 1
|
26
|
+
end
|
27
|
+
|
28
|
+
it "includes a noop lambda" do
|
29
|
+
L.noop.call(1).should be_nil
|
22
30
|
end
|
23
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lambdas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-06-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdoc
|
@@ -67,6 +67,7 @@ extensions: []
|
|
67
67
|
extra_rdoc_files: []
|
68
68
|
files:
|
69
69
|
- .gitignore
|
70
|
+
- .ruby-version
|
70
71
|
- Gemfile
|
71
72
|
- LICENSE
|
72
73
|
- LICENSE.txt
|
@@ -96,9 +97,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
97
|
version: '0'
|
97
98
|
requirements: []
|
98
99
|
rubyforge_project:
|
99
|
-
rubygems_version: 1.8.
|
100
|
+
rubygems_version: 1.8.23
|
100
101
|
signing_key:
|
101
102
|
specification_version: 3
|
102
103
|
summary: A collection of lambdas to use for programming tasks
|
103
104
|
test_files:
|
104
105
|
- spec/lambdas_spec.rb
|
106
|
+
has_rdoc:
|