# Reducible

``public protocol Reducible : Foldable``

Reducible augments the functions provided by `Foldable` with reducing functions that do not need an initial value.

• ``` reduceLeftTo(_:_:_:) ```

Eagerly reduces a structure of values from left to right, also performing a transformation of values.

#### Declaration

Swift

``static func reduceLeftTo<A, B>(_ fa: Kind<Self, A>, _ f: (A) -> B, _ g: (B, A) -> B) -> B``

#### Parameters

 ``` fa ``` Structure of values. ``` f ``` Transforming function. ``` g ``` Folding function.

#### Return Value

Summary value of this reduction.

• ``` reduceRightTo(_:_:_:) ```

Lazily reduces a structure of values from right to left, also performing a transformation of values.

#### Declaration

Swift

``static func reduceRightTo<A, B>(_ fa: Kind<Self, A>, _ f: (A) -> B, _ g: (A, Eval<B>) -> Eval<B>) -> Eval<B>``

#### Parameters

 ``` fa ``` Structure of values. ``` f ``` Transforming function. ``` g ``` Folding function.

#### Return Value

Potentially lazy summary value of this reduction.

• ``` reduceLeft(_:_:) ``` Extension method

Eagerly reduces a structure of values from left to right without transforming them.

#### Declaration

Swift

``static func reduceLeft<A>(_ fa: Kind<Self, A>, _ f: (A, A) -> A) -> A``

#### Parameters

 ``` fa ``` Structure of values. ``` f ``` Folding function.

#### Return Value

Summary value of this reduction.

• ``` reduceRight(_:_:) ``` Extension method

Lazily reduces a structure of values from right to left without transforming them.

#### Declaration

Swift

``static func reduceRight<A>(_ fa: Kind<Self, A>, _ f: (A, Eval<A>) -> Eval<A>) -> Eval<A>``

#### Parameters

 ``` fa ``` Structure of values. ``` f ``` Folding function.

#### Return Value

Potentially lazy summary value of this reduction.

• ``` reduceLeftToOption(_:_:_:) ``` Extension method

Reduces the elements of a structure down to a single value by applying the provided transformation and aggregation funtions in a left-associative manner.

#### Declaration

Swift

``static func reduceLeftToOption<A, B>(_ fa: Kind<Self, A>, _ f: @escaping (A) -> B, _ g: @escaping (B, A) -> B) -> Option<B>``

#### Parameters

 ``` fa ``` Value to be folded. ``` f ``` Transforming function. ``` g ``` Folding function.

#### Return Value

Optional summary value resulting from the folding process. It will be an `Option.none` if the structure is empty, or a value if not.

• ``` reduceRightToOption(_:_:_:) ``` Extension method

Reduces the elements of a structure down to a single value by applying the provided transformation and aggregation functions in a right-associative manner.

#### Declaration

Swift

``static func reduceRightToOption<A, B>(_ fa: Kind<Self, A>, _ f: @escaping (A) -> B, _ g: @escaping (A, Eval<B>) -> Eval<B>) -> Eval<Option<B>>``

#### Parameters

 ``` fa ``` Value to be folded. ``` f ``` Transforming function. ``` g ``` Folding function.

#### Return Value

Optional summary value resulting from the folding process. It will be an `Option.none` if the structure is empty, or a value if not.

• ``` isEmpty(_:) ``` Extension method

Checks if a structure of values is empty.

An instance of `Reducible` is never empty.

#### Declaration

Swift

``static func isEmpty<A>(_ fa: Kind<Self, A>) -> Bool``

#### Parameters

 ``` fa ``` Structure of values.

#### Return Value

`false` if the structure contains any value, `true` otherwise.

• ``` nonEmpty(_:) ``` Extension method

Checks if a structure of values is not empty.

An instance of `Reducible` is always non-empty.

#### Declaration

Swift

``static func nonEmpty<A>(_ fa: Kind<Self, A>) -> Bool``

#### Parameters

 ``` fa ``` Structure of values.

#### Return Value

`true` if the structure contains any value, `false` otherwise.

• ``` reduce(_:) ``` Extension method

Reduces a structure of values to a summary value using the combination capabilities of the `Semigroup` instance of the underlying type.

#### Declaration

Swift

``static func reduce<A>(_ fa: Kind<Self, A>) -> A where A : Semigroup``

#### Parameters

 ``` fa ``` Structure of values.

#### Return Value

Summary value of this reduction.

• ``` reduceMap(_:_:) ``` Extension method

Reduces a structure of values by mapping them to a type with a `Semigroup` instance, and using its combination capabilities.

#### Declaration

Swift

``static func reduceMap<A, B>(_ fa: Kind<Self, A>, _ f: (A) -> B) -> B where B : Semigroup``

#### Parameters

 ``` fa ``` Structure of values. ``` f ``` Mapping function.

#### Return Value

Summary value of this reduction.
{"ft_lang_label":"__label__en","ft_lang_prob":0.514879,"math_prob":0.9342042,"size":3122,"snap":"2019-51-2020-05","text_gpt3_token_len":714,"char_repetition_ratio":0.17703657,"word_repetition_ratio":0.50873363,"special_character_ratio":0.20563741,"punctuation_ratio":0.15114236,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98260653,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-12-10T10:38:33Z\",\"WARC-Record-ID\":\"<urn:uuid:24adb67e-0d58-4b53-b69e-25efc20d3e81>\",\"Content-Length\":\"178042\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:46e26499-ae38-4bfc-822e-a852dde4c4f0>\",\"WARC-Concurrent-To\":\"<urn:uuid:944f53c3-dcc3-430f-9728-37cd805e773f>\",\"WARC-IP-Address\":\"185.199.110.153\",\"WARC-Target-URI\":\"https://bow-swift.io/0.5.0/api-docs/Protocols/Reducible.html\",\"WARC-Payload-Digest\":\"sha1:LGTG5EOTFOZHB4ND3376YTG33PTWJMVD\",\"WARC-Block-Digest\":\"sha1:2TMJ6MJA7W3XXDCK3RUCPADL4JDLK5LJ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-51/CC-MAIN-2019-51_segments_1575540527205.81_warc_CC-MAIN-20191210095118-20191210123118-00428.warc.gz\"}"}