<commit_before># php7-Arrayly
- Arrayly (eager): decorates php array with methods similar to Java Streams / Kotlin Collections
- Sequence (lazy, consume-once): provides fluid interface to php generators
- Flow (lazy, consume-rewindable, FBP): kind of flow-based-programming-style (FBP) for replayable transformations


inspired by 
- nikic/iter: https://github.com/nikic/iter
- Kotlin Collections: https://antonioleiva.com/collection-operations-kotlin/
- Java Stream API: http://winterbe.com/posts/2014/07/31/java8-stream-tutorial-examples/
- Stringy (OO-Style decorator for strings): https://github.com/danielstjules/Stringy

## Alternative Concepts
- Transducers: https://github.com/mtdowling/transducers.php

## Notes
- Experimental.

## Methods
 - filter, map, flatMap, reduce, groupBy, find, sort, ...
 
## Install
    $ composer require bastman/php7-arrayly 0.0.10

## Examples (Arrayly)
- see: tests/examples/arrayly

            Arrayly::ofIterable($cities)
            
            ->map(function ($item) {return $item["country"];})
            ->filter(function ($country) {return $country == 'Germany';})
            ->sortByDescending(function ($a, $b) {return strcasecmp($a, $b);})
            ->drop(1)
            ->take(2)
            
            ->toArray();
-             
            Arrayly::ofIterable($cities)
                        ->groupBy(function (array $item):string {
                            return $item["country"];
                        })
                        ->flatMap(function (array $itemGroup):array {<commit_msg>- new version: 0.0.10 - mapKeys() - and it's variants made consistent / self-speaking<commit_after># php7-Arrayly
- Arrayly (eager): decorates php array with methods similar to Java Streams / Kotlin Collections
- Sequence (lazy, consume-once): provides fluid interface to php generators & iterators
- Flow (lazy, consume-rewindable, FBP): kind of flow-based-programming-style (FBP) for replayable transformation pipelines


inspired by 
- nikic/iter: https://github.com/nikic/iter
- Kotlin Collections: https://antonioleiva.com/collection-operations-kotlin/
- Java Stream API: http://winterbe.com/posts/2014/07/31/java8-stream-tutorial-examples/
- Stringy (OO-Style decorator for strings): https://github.com/danielstjules/Stringy

## Alternative Concepts
- Transducers: https://github.com/mtdowling/transducers.php

## Notes
- Experimental.

## Design Principles
- functional programming
- immutability

## Methods
 - filter, map, flatMap, reduce, groupBy, find, sort, ...
 
## Install
    $ composer require bastman/php7-arrayly 0.0.10

## Examples (Arrayly)
- see: tests/examples/arrayly

            Arrayly::ofIterable($cities)
            
            ->map(function ($item) {return $item["country"];})
            ->filter(function ($country) {return $country == 'Germany';})
            ->sortByDescending(function ($a, $b) {return strcasecmp($a, $b);})
            ->drop(1)
            ->take(2)
            
            ->toArray();
-             
            Arrayly::ofIterable($cities)
                        ->groupBy(function (array $item):string {
                            return $item["country"];
                        })
                        ->flatMap(function (array $itemGroup):array {
{'fraction_non_alphanumeric': 0.13374045801526718, 'fraction_numerical': 0.011603053435114504, 'mean_word_length': 2.5037433155080215, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '581575', 'n_tokens_mistral': 1002, 'n_tokens_neox': 924, 'n_words': 223}