Jikka-5.0.11.1: A transpiler from Python to C++ for competitive programming

Jikka.Core.Convert.CloseMin

Description

Synopsis

# Documentation

run :: (MonadAlpha m, MonadError Error m) => Program -> m Program Source #

run reduces maximums and minimums.

## Examples

Before:

max (map (fun x -> 3 + f x) xs)

After:

3 + max (map f xs)

## List of builtin functions which are reduced

$\newcommand\int{\mathbf{int}} \newcommand\bool{\mathbf{bool}} \newcommand\list{\mathbf{list}}$

### Target functions

• Max1 $$: \forall \alpha. \list(\alpha) \to \alpha$$
• Min1 $$: \forall \alpha. \list(\alpha) \to \alpha$$
• ArgMax $$: \forall \alpha. \list(\alpha) \to \int$$
• ArgMin $$: \forall \alpha. \list(\alpha) \to \int$$

### Related functions

• Max2 $$: \forall \alpha. \alpha \to \alpha \to \alpha$$
• Min2 $$: \forall \alpha. \alpha \to \alpha \to \alpha$$

### List Build functions

• Nil $$: \forall \alpha. \list(\alpha)$$
• Cons $$: \forall \alpha. \alpha \to \list(\alpha) \to \list(\alpha)$$
• Range1 $$: \int \to \list(\int)$$

### List Map functions

• Map $$: \forall \alpha \beta. (\alpha \to \beta) \to \list(\alpha) \to \list(\beta)$$
• Filter $$: \forall \alpha \beta. (\alpha \to \bool) \to \list(\alpha) \to \list(\beta)$$
• Reversed $$: \forall \alpha. \list(\alpha) \to \list(\alpha)$$
• Sorted $$: \forall \alpha. \list(\alpha) \to \list(\alpha)$$

# internal rules

TODO: implement this

TODO: implement this