#![feature(conservative_impl_trait)]
use std::clone::Clone;
pub fn idiot<A>(x: A) -> A {
x
}
pub fn kestrel<A, B>(x: A, _: B) -> A {
x
}
pub fn bluebird<A, B, C, F, G>(f: F, g: G) -> impl Fn(A) -> C
where
F: Fn(B) -> C,
G: Fn(A) -> B,
{
move |x| f(g(x))
}
pub fn cardinal<A, B, C, F>(f: F) -> impl Fn(B, A) -> C
where
F: Fn(A, B) -> C
{
move |a, b| f(b, a)
}
pub fn applicator<A, B, F>(f: F) -> impl Fn(A) -> B
where
F: Fn(A) -> B
{
move |a| f(a)
}
pub fn psi<A, B, C, F, G>(f: F, g: G) -> impl Fn(A, A) -> C
where
F: Fn(B, B) -> C,
G: Fn(A) -> B,
{
move |a, b| f(g(a), g(b))
}
pub fn becard<A, B, C, D, F, G, H>(f: F, g: G, h: H) -> impl Fn(A) -> D
where
F: Fn(C) -> D,
G: Fn(B) -> C,
H: Fn(A) -> B,
{
move |a| f(g(h(a)))
}
pub fn bluebird_prime<A: Clone, B, C, D, F, G>(f: F, a: A, g: G) -> impl Fn(B) -> D
where
F: Fn(A, C) -> D,
G: Fn(B) -> C,
{
move |b| f(a.clone(), g(b))
}
pub fn blackbird<A, B, C, D, F, G>(f: F, g: G) -> impl Fn(A, B) -> D
where
F: Fn(C) -> D,
G: Fn(A, B) -> C
{
move |x, y| f(g(x, y))
}
pub fn bunting<A, B, C, D, E, F, G>(f: F, g: G) -> impl Fn(A, B, C) -> E
where
F: Fn(D) -> E,
G: Fn(A, B, C) -> D
{
move |x, y, z| f(g(x, y, z))
}
pub fn cardinal_prime<A, B, C, D, F, G>(f: F, g: G) -> impl Fn(A, B) -> D
where
F: Fn(C, A) -> D,
G: Fn(B) -> C
{
move |x, y| f(g(y), x)
}
pub fn cardinalstar<A, B, C, D, F>(f: F) -> impl Fn(A, B, C) -> D
where
F: Fn(A, C, B) -> D,
{
move |x, y, z| f(x, z, y)
}
pub fn cardinalstarstar<A, B, C, D, E, F>(f: F) -> impl Fn(A, B, C, D) -> E
where
F: Fn(A, B, D, C) -> E,
{
move |s, t, u, v| f(s, t, v, u)
}
pub fn dickcissel<A: Clone, B: Clone, C, D, E, F, G>(f: F, x: A, y: B, g: G) -> impl Fn(C) -> E
where
F: Fn(A, B, D) -> E,
G: Fn(C) -> D,
{
move |z| f(x.clone(), y.clone(), g(z))
}
pub fn dove<A: Clone, B, C, D, F, G>(f: F, x: A, g: G) -> impl Fn(B) -> D
where
F: Fn(A, C) -> D,
G: Fn(B) -> C,
{
move |y| f(x.clone(), g(y))
}
pub fn dovekie<A: Clone, B, C, D, E, F, G, H>(f: F, g: G, x: A, h: H) -> impl Fn(B) -> E
where
F: Fn(C, D) -> E,
G: Fn(A) -> C,
H: Fn(B) -> D,
{
move |z| f(g(x.clone()), h(z))
}
pub fn eagle<A: Clone, B, C, D, E, F, G>(f: F, x: A, g: G) -> impl Fn(B, C) -> E
where
F: Fn(A, D) -> E,
G: Fn(B, C) -> D,
{
move |y, z| f(x.clone(), g(y, z))
}
pub fn eaglebald<A: Clone, B: Clone, C, D, E, F, G, H, U, V>(f: H, g: U, s: A, t: B, h: V) -> impl Fn(C, D) -> G
where
H: Fn(E, F) -> G,
U: Fn(A, B) -> E,
V: Fn(C, D) -> F,
{
move |u, v| f(g(s.clone(), t.clone()), h(u, v))
}
pub fn finch<A, B, C, F>(x: A, y: B, f: F) -> C
where
F: Fn(B, A) -> C,
{
f(y, x)
}
pub fn finchstar<A, B, C, D, F>(f: F) -> impl Fn(A, B, C) -> D
where
F: Fn(C, B, A) -> D,
{
move |x, y, z| f(z, y, x)
}
pub fn finchstarstar<A, B, C, D, E, F>(f: F) -> impl Fn(A, B, C, D) -> E
where
F: Fn(A, D, C, B) -> E
{
move |s, t, u, v| f(s, v, u, t)
}
pub fn goldfinch<A, B, C, D, F, G>(f: F, g: G) -> impl Fn(A, B) -> D
where
F: Fn(B, C) -> D,
G: Fn(A) -> C,
{
move |x, y| f(y, g(x))
}
pub fn hummingbird<A: Clone, B, C, F>(f: F) -> impl Fn(A, B) -> C
where
F: Fn(A, B, A) -> C,
{
move |x, y| f(x.clone(), y, x)
}
pub fn idstar<A, B, F>(f: F) -> impl Fn(A) -> B
where
F: Fn(A) -> B,
{
move |x| f(x)
}
pub fn idstarstar<A, B, C, F>(f: F) -> impl Fn(A, B) -> C
where
F: Fn(A, B) -> C,
{
move |x, y| f(x, y)
}
pub fn jalt<A, B, C, F>(f: F) -> impl Fn(A, B) -> C
where
F: Fn(A) -> C,
{
move |x, _| f(x)
}
pub fn jalt_prime <A, B, C, D, F>(f: F) -> impl Fn(A, B, C) -> D
where
F: Fn(A, B) -> D,
{
move |x, y, _| f(x, y)
}
pub fn jay<A, B, F>(f: F) -> impl Fn(A, B, A) -> B
where
F: Fn(A, B) -> B,
{
move |x, y, z| f(x, f(z, y))
}
pub fn kite<A, B>(_: A, b: B) -> B
{
b
}
pub fn owl<A: Clone, B, C, D, F, G, H>(f: F, x: A, g: G) -> impl Fn(D) -> C
where
F: Fn(A, B) -> C,
G: Fn(D) -> B,
{
move |b| f(x.clone(), g(b))
}
pub fn phoenix<A: Clone, B, C, D, F, G, H>(f: F, g: G, h: H) -> impl Fn(A) -> D
where
F: Fn(B, C) -> D,
G: Fn(A) -> B,
H: Fn(A) -> C,
{
move |x| f(g(x.clone()), h(x))
}
pub fn quacky<A, B, C, F, G>(x: A, f: F, g: G) -> C
where
F: Fn(A) -> B,
G: Fn(B) -> C,
{
g(f(x))
}
pub fn queer<A, B, C, F, G>(f: F, g: G) -> impl Fn(A) -> C
where
F: Fn(A) -> B,
G: Fn(B) -> C,
{
move |x| g(f(x))
}
pub fn quirky<A, B, C, F, G>(f: F, x: A, g: G) -> C
where
F: Fn(A) -> B,
G: Fn(B) -> C,
{
g(f(x))
}
pub fn quixotic<A, B, C, F, G>(f: F, x: A, g: G) -> C
where
F: Fn(B) -> C,
G: Fn(A) -> B,
{
f(g(x))
}
pub fn quizzical<A, B, C, F, G>(x: A, f: F, g: G) -> C
where
F: Fn(B) -> C,
G: Fn(A) -> B,
{
f(g(x))
}
pub fn robin<A: Clone, B, C, F>(x: A, f: F) -> impl Fn(B) -> C
where
F: Fn(B, A) -> C,
{
move |y| f(y, x.clone())
}
pub fn robinstar<A, B, C, D, F>(f: F) -> impl Fn(A, B, C) -> D
where
F: Fn(B, C, A) -> D,
{
move |x, y, z| f(y, z, x)
}
pub fn robinstarstar<A, B, C, D, E, F>(f: F) -> impl Fn(A, B, C, D) -> E
where
F: Fn(A, C, D, B) -> E,
{
move |s, t, u, v| f(s, u, v, t)
}
pub fn starling<A: Clone, B, C, F, G>(f: F, g: G) -> impl Fn(A) -> C
where
F: Fn(A, B) -> C,
G: Fn(A) -> B,
{
move |x| f(x.clone(), g(x))
}
pub fn starling_prime<A: Clone, B, C, D, F, G, H>(f: F, g: G, h: H) -> impl Fn(A) -> D
where
F: Fn(B, C) -> D,
G: Fn(A) -> B,
H: Fn(A) -> C,
{
move |x| f(g(x.clone()), h(x))
}
pub fn thrush<A, B, F>(x: A, f: F) -> B
where
F: Fn(A) -> B,
{
f(x)
}
pub fn vireo<A, B, C, F>(x: A, y: B, f: F) -> C
where
F: Fn(A, B) -> C,
{
f(x, y)
}
pub fn vireostar<A, B, D, F>(f: F) -> impl Fn(A, B, B) -> D
where
F: Fn(B, A, B) -> D,
{
move |x, y, z| f(y, x, z)
}
pub fn vireostarstar<A, B, C, E, F>(f: F) -> impl Fn(A, B, C, C) -> E
where
F: Fn(A, C, B, C) -> E,
{
move |s, t, u, v| f(s, v, t, u)
}
pub fn warbler<A: Clone, B, F>(f: F) -> impl Fn(A) -> B
where
F: Fn(A, A) -> B,
{
move |x| f(x.clone(), x)
}
pub fn warbler1<A: Clone, B, F>(x: A, f: F) -> B
where
F: Fn(A, A) -> B,
{
f(x.clone(), x)
}
pub fn warblerstar<A, B: Clone, C, F>(f: F) -> impl Fn(A, B) -> C
where
F: Fn(A, B, B) -> C,
{
move |x, y| f(x, y.clone(), y)
}
pub fn warblerstarstar<A, B, C: Clone, D, F>(f: F) -> impl Fn(A, B, C) -> D
where
F: Fn(A, B, C, C) -> D,
{
move |x, y, z| f(x, y, z.clone(), z)
}
#[cfg(test)]
mod test {
use std::cmp::PartialEq;
use ::starling;
#[test]
fn palindrome() {
let eq = &(|x: String, y: String| PartialEq::eq(&x, &y)) as &Fn(String, String) -> bool;
let reverse = |x: String| x.chars().rev().collect::<String>();
let is_palindrome = starling(&eq, &reverse);
assert!(is_palindrome("nisumaa oli isäsi ilo aamusin".to_string()));
}
}