<commit_before>+++
title = "2n: Functional Hacks"
weight = 17
template = "doc.html"
+++

### `++cork`

Compose forward

Build `f` such that `(f x) .= (b (a x))`.

#### Accepts

`a` is a noun.

`b` is a gate.

#### Source

```hoon
    ++  cork  |*([a=_|=(* **) b=gate] (corl b a))
```

#### Examples

```
    > (:(cork dec dec dec) 20)
    17

    > =mal (mo (limo a+15 b+23 ~))
    > ((cork ~(got by mal) dec) %a)
    14

    > ((cork ~(got by mal) dec) %b)
    22
```

---
### `++corl`

Compose backward

Build `f` such that

#### Accepts

`a` is a gate.

`b` is a noun.

#### Source

```hoon
    ++  corl
      |*  [a=gate b=_|=(* **)]
      =<  +:|.((a (b)))      ::  span check
      |*  c=_+<.b
      (a (b c))
```<commit_msg>update stdlib cork code, fix example<commit_after>+++
title = "2n: Functional Hacks"
weight = 17
template = "doc.html"
+++

### `++cork`

Compose forward

Build `f` such that `(f x) .= (b (a x))`.

#### Accepts

`a` is a noun.

`b` is a gate.

#### Source

```hoon
++  cork  |*([a=$-(* *) b=$-(* *)] (corl b a))
```

#### Examples

```
    > (:(cork dec dec dec) 20)
    17
    
    > `@ub`(bex (met 0 23))
    0b10.0000
    
    > `@ub`((cork (cury met 0) bex) 23)
    0b10.0000
```

---
### `++corl`

Compose backward

Build `f` such that

#### Accepts

`a` is a gate.

`b` is a noun.

#### Source

```hoon
++  corl                                                ::  compose backwards
  |*  [a=$-(* *) b=$-(* *)]
  =<  +:|.((a (b)))      ::  type check
  =+  c=+<.b
  |@  ++  $  (a (b c))
  --
```
{'fraction_non_alphanumeric': 0.2581699346405229, 'fraction_numerical': 0.027450980392156862, 'mean_word_length': 2.06813627254509, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4655998', 'n_tokens_mistral': 730, 'n_tokens_neox': 680, 'n_words': 186}