compose-everything 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +8 -0
- data/Rakefile +1 -0
- data/compose-everything.gemspec +15 -0
- data/lib/composeeverything.rb +3 -0
- data/lib/composeeverything/functionalgoodies.rb +59 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5df278d3f36799d406abc305477c9b52c08a90f9
|
4
|
+
data.tar.gz: 48bc676d001c973a3e286e452f03f2cd51044e2a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ab3118b0b391fa2db0ef3eb75c72b25a01e8129266e82083988e71c29aba6402e4e9e557e19f0ab2902deec1e758eb6b6356d1b5cea63af0e330caf6a6dfe1cd
|
7
|
+
data.tar.gz: 05785924ffaddaf3c0878f7ea44f161522307ab9e1a850c72a6653eb1592b363ea874191696193192bb991941c79f4785b4ce79130af98c60fd0fe7693542338
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 trajing
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = 'compose-everything'
|
3
|
+
spec.version = '0.0.0'
|
4
|
+
spec.authors = ['trajing']
|
5
|
+
spec.email = ['trajingplaysgames@gmail.com']
|
6
|
+
|
7
|
+
spec.summary = 'Composition and other functional goodies for objects supporting the #[] and #[]= methods.'
|
8
|
+
spec.license = 'MIT'
|
9
|
+
|
10
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
11
|
+
spec.require_paths = ["lib"]
|
12
|
+
|
13
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
14
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
15
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module ComposeEverything::FunctionalGoodies
|
2
|
+
def compose(with)
|
3
|
+
->(x) { with[self[x]] }
|
4
|
+
end
|
5
|
+
|
6
|
+
def f_map(func)
|
7
|
+
compose(func)
|
8
|
+
end
|
9
|
+
|
10
|
+
def f_flat_map(func)
|
11
|
+
->(x) {
|
12
|
+
self[x].f_map(func)
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def f_filter(func)
|
17
|
+
filter_indexed ->(idx, x) {
|
18
|
+
func[x]
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def filter_indexed(func)
|
23
|
+
->(x) {
|
24
|
+
a = self[x]
|
25
|
+
func[x, a] ? a : nil
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def f_add(idx, output)
|
30
|
+
union ->(x) {
|
31
|
+
output if x == idx
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def intersection(with)
|
36
|
+
filter_indexed ->(idx, x) {
|
37
|
+
x == with[idx]
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def union(with)
|
42
|
+
->(x) {
|
43
|
+
a = self[x]
|
44
|
+
y.nil? ? a : with[x]
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def f_delete(a)
|
49
|
+
remove ->(x) {
|
50
|
+
a
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def remove(removed)
|
55
|
+
filter_indexed ->(idx, x) {
|
56
|
+
removed[idx] != x
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: compose-everything
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- trajing
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- trajingplaysgames@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".travis.yml"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- compose-everything.gemspec
|
55
|
+
- lib/composeeverything.rb
|
56
|
+
- lib/composeeverything/functionalgoodies.rb
|
57
|
+
homepage:
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.4.5
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: 'Composition and other functional goodies for objects supporting the #[]
|
81
|
+
and #[]= methods.'
|
82
|
+
test_files: []
|