README.md in canal-0.0.1 vs README.md in canal-0.0.2
- old
+ new
@@ -1,20 +1,55 @@
# Canal
-Partial application of a chain of methods.
+Build functions out of methods.
-## Example
+## Examples
Canal can allow point-free expressions. For example, when using `map`:
```ruby
%w{10010101 11100 10110}.map(&canal.to_i(2).to_s.reverse.to_i.to_s(2))
```
+is equivalent to
+
```ruby
%w{10010101 11100 10110}.map do |x|
x.to_i(2).to_s.reverse.to_i.to_s(2)
end
+```
+
+### Identity
+
+An empty canal is the identity function.
+
+```ruby
+[1, 2, 3].map(&canal)
+=> [1, 2, 3]
+```
+
+Exemple: Count truthy values.
+
+```ruby
+[true, false, nil, "hey", 4].count(&canal)
+=> 3
+```
+
+### Operators
+
+Fetch key in list of hash.
+
+```ruby
+people = [{ name: "Alice" }, { name: "Bob" }]
+people.map(&canal[:name])
+=> ["Alice", "Bob"]
+```
+
+Multiply list of number by 2.
+
+```ruby
+(0..5).map(&canal * 2)
+=> [0, 2, 4, 6, 8, 10]
```
## Installation
Add this line to your application's Gemfile: