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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f43de20a0dc3027e2e901c3c95d10e362aa4206
4
- data.tar.gz: c65128a10ef09ee9c6d04c00eab1e67892f0636a
3
+ metadata.gz: 81b06431cb27f355d7665ea205cc7a6eafbab5a5
4
+ data.tar.gz: 7f1d6336b52d4f46b5014a1511ac934a1f6b64de
5
5
  SHA512:
6
- metadata.gz: 0ae7997b73af3aca89dd773967a44eda8ce37da2234bf89763b7caaa633f956cac3046220cc1da9d697a52b4058ada4a028265d5d628c5d4ccd590fbbaafce31
7
- data.tar.gz: bd2147d3a6d3735365da8d6f93b22ec55d7607595e2b617f3ce173a57641125abec8c6a623ba1948fe03b16409d20bad7939f9d3d605b982477e4bf0c88b7580
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 #car, #cdr, #caar, #cdar, #cadr, #cddr...
22
- When you `require 'pyper'` and `include Pyper`, you can try them by yourself:
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, #caar will return the first element of the first element, #cadr
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 widely extends the idea:
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
- 'τ', 'π', 'χ' (small Greek tau, pi and chi). Choice of the character
47
- conveys specific meaning, which is best explained by case enumeration:
48
-
49
- τ...τ means single-pipe input and output,
50
- τ...π means single-pipe input, double-pipe output
51
- τ...χ means single-pipe input, double-pipe output with a swap
52
- π...τ means double-pipe input, single-pipe output
53
- . . .
54
- χ...χ means double-pipe input with a swap, and same for the output
55
-
56
- (Mnemonic for this is, that τ has one (vertical) pipe, π has two pipes,
57
- and χ looks like two pipes crossed)
58
-
59
- As for the meaning, single-pipe input means, that a single object (the
60
- message receiver) is fed to the pipeline. Double-pipe input means, that
61
- the receiver is assumed to respond to methods #size and #[], its size is
62
- 2, and this being fulfilled, pipeline 0 and 1 are initialized
63
- respectively with the first and second element of the receiver as per
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
- ["See", "you", "later", "alligator"].τdτ = ["you", "later", "alligator"]
89
- ["See", "you", "later", "alligator"].τeτ = ["later", "alligator"]
90
- ["See", "you", "later", "alligator"].τfτ = ["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τ = ["later", "alligator"]
97
- ["See", "you", "later", "alligator"].τdeτ = ["alligator"]
98
- ["See", "you", "later", "alligator"].τdeaτ = "alligator"
99
- ["See", "you", "later", "alligator"].τdeadτ = "lligator"
100
- ["See", "you", "later", "alligator"].τdeafτ = "igator"
101
- ["See", "you", "later", "alligator"].τdeafbτ = "g"
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
- PostfixMachine code as their documentation.
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.
@@ -20,6 +20,12 @@ module Enumerable
20
20
  include Pyper
21
21
  end
22
22
 
23
+ # Pyper is by default included in Enumerable.
24
+ #
25
+ class Enumerator
26
+ include Pyper
27
+ end
28
+
23
29
  # Pyper is by default included in Array.
24
30
  #
25
31
  class Array
@@ -1,4 +1,4 @@
1
1
  module Pyper
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  DEBUG = 0 # debug level
4
4
  end
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.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-07-21 00:00:00.000000000 Z
11
+ date: 2013-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shoulda