pyper 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +42 -61
- data/lib/pyper/default_includes.rb +6 -0
- data/lib/pyper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81b06431cb27f355d7665ea205cc7a6eafbab5a5
|
4
|
+
data.tar.gz: 7f1d6336b52d4f46b5014a1511ac934a1f6b64de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba7846834b085f39251741f3d0398e0c65c778294b286fc8e937065dc33b04bcbd80f767efe86325accadef000fe527929c71ac1d10c06639485bad77e2d967c
|
7
|
+
data.tar.gz: 595db729e3fe019c39c2f136e3963d1d9d893d3868cd490c052beebedb9699865c98e19ffa1d3a11f16804c9278edea9201be86b418e98f181a60e3d7699c897
|
data/README.md
CHANGED
@@ -2,29 +2,18 @@
|
|
2
2
|
|
3
3
|
Pyper is a wide extension of the Lispy car/cdr idea.
|
4
4
|
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'pyper'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install pyper
|
18
|
-
|
19
5
|
## Usage
|
20
6
|
|
21
|
-
Everybody knows Lispy functions
|
22
|
-
|
7
|
+
Everybody knows Lispy functions `#car`, `#cdr`, `#caar`, `#cdar`, `#cadr`, `#cddr`...
|
8
|
+
With Pyper, you have them at the hand:
|
9
|
+
```ruby
|
10
|
+
require 'pyper'
|
23
11
|
|
24
12
|
[1, 2, 3].car # will return the first element, 1
|
25
13
|
[1, 2, 3].cdr # will return the remaining elements, [2, 3]
|
14
|
+
```
|
26
15
|
|
27
|
-
Similarly,
|
16
|
+
Similarly, `#caar` will return the first element of the first element, `#cadr`
|
28
17
|
will return the first element of the remaining elements (that is, second
|
29
18
|
element), #cddr will return the list of [3rd, 4th, ... ] elements, etc.
|
30
19
|
|
@@ -36,34 +25,31 @@ caaaaar, ..., cadaadr, ...
|
|
36
25
|
|
37
26
|
In effect, such character sequences form an APL-like language consisting of
|
38
27
|
one-character operators 'a' and 'd', whose combination determines the overall
|
39
|
-
operation. Pyper adds a few modifications and
|
28
|
+
operation. Pyper adds a few modifications and extends the idea:
|
40
29
|
|
41
30
|
1. Twin-barrel piping: Instead of just one pipeline, in which the
|
42
31
|
operations are applied in sequence, Pyper has 2 parallel pipelines.
|
43
32
|
|
44
33
|
2. Greek letters τ, π, χ as method delimiters: Instead of 'c' and 'r' of
|
45
34
|
car/cdr family, Pyper methods start and end with any of the characters
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
. . .
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
and χ looks like two pipes crossed
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
method #[]. Double-pipe input with swap is the same, but the two
|
65
|
-
elements of the receiver are swapped: pipeline 1 receives the first,
|
66
|
-
pipeline 0 the second.
|
35
|
+
`τ`, `π`, `χ` (_tau_, _pi_ and _chi_). Their meaning is best explained by
|
36
|
+
examples:
|
37
|
+
|
38
|
+
* `τ...τ` means single-pipe input and output,
|
39
|
+
* `τ...π` means single-pipe input, double-pipe output
|
40
|
+
* `τ...χ` means single-pipe input, double-pipe output with a swap
|
41
|
+
* `π...τ` means double-pipe input, single-pipe output
|
42
|
+
* . . .
|
43
|
+
* `χ...χ` means double-pipe input with a swap, and same for the output
|
44
|
+
|
45
|
+
Mnemonic for this is, that τ looks like a gutter (has one vertical pipe),
|
46
|
+
π looks like a twin gutter (two pipes) and χ looks like two pipes crossed.
|
47
|
+
Single-pipe input means, that a single object (the receiver) is fed to the
|
48
|
+
pipeline 0, while pipeline 1 receives its copy. Double-pipe input means,
|
49
|
+
that the receiver should respond to #size and #[], and its size should be 2.
|
50
|
+
Pipelines 0 and 1 are then initialized respectively with the first and
|
51
|
+
the second element (obtained by #[]). Double-pipe input with swap is the
|
52
|
+
same, but the two elements are swapped.
|
67
53
|
|
68
54
|
3. Postfix order of commands: While traditional car/cdr family of
|
69
55
|
methods applies the letters in the prefix order (from right to left),
|
@@ -78,27 +64,31 @@ and 'd', is greatly extended.
|
|
78
64
|
|
79
65
|
For example, apart from 'a', mening first, 'b' means second, and 'c'
|
80
66
|
means third:
|
81
|
-
|
67
|
+
```ruby
|
82
68
|
["See", "you", "later", "alligator"].τaτ #=> "See"
|
83
69
|
["See", "you", "later", "alligator"].τbτ #=> "you"
|
84
70
|
["See", "you", "later", "alligator"].τcτ #=> "later"
|
71
|
+
```
|
85
72
|
|
86
73
|
For another example, apart from 'd', meaning all except first, 'e' means
|
87
74
|
all except first two, and 'f' means all except first three:
|
88
|
-
|
89
|
-
["See", "you", "later", "alligator"].τ
|
90
|
-
["See", "you", "later", "alligator"].τ
|
75
|
+
```ruby
|
76
|
+
["See", "you", "later", "alligator"].τdτ #=> ["you", "later", "alligator"]
|
77
|
+
["See", "you", "later", "alligator"].τeτ #=> ["later", "alligator"]
|
78
|
+
["See", "you", "later", "alligator"].τfτ #=> ["alligator"]
|
79
|
+
```
|
91
80
|
|
92
81
|
These command characters can be combined just like 'a' and 'd' letters
|
93
82
|
in the traditional car/cdr family - just beware of the Pyper's postfix
|
94
83
|
order:
|
95
|
-
|
96
|
-
["See", "you", "later", "alligator"].τddτ
|
97
|
-
["See", "you", "later", "alligator"].τdeτ
|
98
|
-
["See", "you", "later", "alligator"].τdeaτ
|
99
|
-
["See", "you", "later", "alligator"].τdeadτ
|
100
|
-
["See", "you", "later", "alligator"].τdeafτ
|
101
|
-
["See", "you", "later", "alligator"].τdeafbτ
|
84
|
+
```ruby
|
85
|
+
["See", "you", "later", "alligator"].τddτ #=> ["later", "alligator"]
|
86
|
+
["See", "you", "later", "alligator"].τdeτ #=> ["alligator"]
|
87
|
+
["See", "you", "later", "alligator"].τdeaτ #=> "alligator"
|
88
|
+
["See", "you", "later", "alligator"].τdeadτ #=> "lligator"
|
89
|
+
["See", "you", "later", "alligator"].τdeafτ #=> "igator"
|
90
|
+
["See", "you", "later", "alligator"].τdeafbτ #=> "g"
|
91
|
+
```
|
102
92
|
|
103
93
|
Allready with these few command characters (a-c, d-f, u-w, x-z, plus
|
104
94
|
numbers 0-4 and 5-9), one can compose intelligent car/cdr-like methods.
|
@@ -116,14 +106,5 @@ as their arity requires.
|
|
116
106
|
|
117
107
|
So much for the main concepts. As for the character meanings, those are
|
118
108
|
defined as PostfixMachine methods of the same name (the name consists of
|
119
|
-
1 or 2 characters). At the moment, it is necessary to read the
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
## Contributing
|
124
|
-
|
125
|
-
1. Fork it
|
126
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
127
|
-
3. Commit your changes (`git commit -am 'Added some feature'`)
|
128
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
129
|
-
5. Create new Pull Request
|
109
|
+
1 or 2 characters). At the moment, it is necessary to read the code for
|
110
|
+
their documentation.
|
data/lib/pyper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pyper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- boris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shoulda
|