totally_lazy 0.1.54 → 0.1.55
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/totally_lazy/pair.rb +8 -0
- data/readme.md +49 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MGFjNjY5NzI0NjAzMDgyZThjYTA3MTUxYWI0YTBiNzk0ZmZkMDA5ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmU1MjQ0YzVmOThmMjYzMTVlODlmODY3Yzc4OWE0OWUxMzc5YTI0Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2ZiYzJjOTZlNjZlN2Y5NmJkNDM5ZmNmYTY1MThiODQyYzgyNGU0OTkwOWJk
|
10
|
+
ODk3ZjhmNDJjNGVhZmZhYTRmNGMzMjQyMjJmYjdmYzI2MDAyNTIyYzdkOTRi
|
11
|
+
MTU1ZWIxYmUxYjQwZmEzZTlmOTE2YTkyNjRjMjNkNzhkNDliNmE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTNkYWNmODE3OTVjY2QzZWRmM2UyMWFmZDZlODM4N2M4OTY3MTk1MTJkMDI0
|
14
|
+
ZGFhOTAxZDRjZDdiYzg5MTc3MDdmZDZkMDViOWZiNjY1ZDhhYTMwZDA3YTVk
|
15
|
+
OGNmNjhjMTZkYjA2ZjAzMWU1YmFjMmVkY2RhNGNmYTFhMDA1OTM=
|
data/lib/totally_lazy/pair.rb
CHANGED
data/readme.md
CHANGED
@@ -1,4 +1,50 @@
|
|
1
|
-
|
2
|
-
============
|
1
|
+
# Totally Lazy for Ruby
|
3
2
|
|
4
|
-
[
|
3
|
+
This is a port of the java functional library [Totally Lazy](https://code.google.com/p/totallylazy/) to the ruby language.
|
4
|
+
|
5
|
+
### Status
|
6
|
+
[![Build Status](https://travis-ci.org/raymanoz/totally_lazy.svg?branch=master)](https://travis-ci.org/raymanoz/totally_lazy)
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/totally_lazy.svg)](https://badge.fury.io/rb/totally_lazy)
|
8
|
+
|
9
|
+
### Summary
|
10
|
+
|
11
|
+
* Tries to be as lazy as possible
|
12
|
+
* Supports method chaining
|
13
|
+
* Is primarily based on ruby Enumerators
|
14
|
+
* For function, can use blocks or lambdas (some places require lambdas, eg. when 2 functions need to be passed in)
|
15
|
+
|
16
|
+
### Install
|
17
|
+
|
18
|
+
This gem requires ruby >= 2.0.0
|
19
|
+
|
20
|
+
In your bundler Gemfile
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem totally_lazy, '~>0.1.54' (or latest)
|
24
|
+
```
|
25
|
+
|
26
|
+
Or with rubygems
|
27
|
+
|
28
|
+
```
|
29
|
+
gem install totally_lazy
|
30
|
+
```
|
31
|
+
|
32
|
+
### Examples
|
33
|
+
|
34
|
+
The following are some simple examples of the currently implemented functionality.
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
require 'totally_lazy'
|
38
|
+
|
39
|
+
sequence(1,2,3,4).filter(even) # lazily returns 2,4
|
40
|
+
sequence(1,2).map(to_string) # lazily returns "1","2"
|
41
|
+
sequence(1, 2).map_concurrently(to_string) # lazily distributes the work to background threads
|
42
|
+
sequence(1,2,3).take(2) # lazily returns 1,2
|
43
|
+
sequence(1,2,3).drop(2) # lazily returns 3
|
44
|
+
sequence(1,2,3).tail # lazily returns 2,3
|
45
|
+
sequence(1,2,3).head # eagerly returns 1
|
46
|
+
sequence(1,2,3).head_option # eagerly returns an option
|
47
|
+
some(sequence(1,2,3)).get_or_else(empty) # eagerly returns value or else empty sequence
|
48
|
+
sequence(1, 2, 3, 4, 5).filter(greater_than(2).and(odd)) # lazily returns 3,5
|
49
|
+
sequence(pair(1, 2), pair(3, 4)).filter(where(first, equal_to?(3))) # lazily returns pair(3,4)
|
50
|
+
```
|