Not an interpreter. Arguably a compiler. But I'm talking about a transpiler.

It can be in any language, but it must return js-valid arrow notation code.

The λ-calculus string would be passed as an argument to a function, or the whole program, and in some way the program would return/log/print the string with the js-notation.

Whitespace is not important, if it makes the writing easier.

Only accepted answers are with curry notation for output, not multiple parameters. The λ-calculus notation shorthand for multiple parameters must be considered.

All identifiers will be separated either by a (space), a λ, a . or () (parentheses). They can be more than a single character. Note that if the language has issues with keeping track of characters like λ, then you can cut yourself some slack and use \.

The transpiler doesn't have to evaluate the expression to simplify it, but as long as the statement is equivalent, I'll allow it. It won't gain any extra points.

All unneeded parenthesis can be taken out. x=>x is just as valid as (x=>x) which is just as valid as ((x)=>x) or (x)=>x.

Using non arrow-function javascript features is disallowed, although if you come up with interesting hacks, they might be worth checking out, so feel free to ask if you have something creative.

Efficiency isn't really important, as long as vaguely practical, so answer with least amount of bytes wins


λx.x                -> (x)=>x
λx y.x(y)           -> (x)=>(y)=>x(y)
λx.λy.x(y)          -> (x)=>(y)=>x(y)
λs z.s(s z)         -> (s)=>(z)=>s(s(z))
λfoo bar.foo bar    -> (foo)=>(bar)=>foo(bar)
(λa b c.b c a) x y -> ((a)=>(b)=>(c)=>(b(c)(a)))(x)(y)
  • \$\begingroup\$ Are the legal JS forms which do not use excess ()s also fine? i.e. λx.x -> x=>x? \$\endgroup\$ – Benjamin Gruenbaum Mar 15 '17 at 22:52
  • \$\begingroup\$ yeah. Added them in for clarity. I'll specify it \$\endgroup\$ – towc Mar 15 '17 at 22:53
  • 1
    \$\begingroup\$ You should talk about the precise definition of a lambda so that the post is self-contained and on-topic. \$\endgroup\$ – Conor O'Brien Mar 15 '17 at 23:30
  • 1
    \$\begingroup\$ @ConorO'Brien how do you suggest I should do that? Post a few resources indicating what lambda calculus is? Maybe just the wiki page? If there was any question of ambiguity, I would have thought that the examples would answer them \$\endgroup\$ – towc Mar 15 '17 at 23:49
  • \$\begingroup\$ I agree with Conor. Without an in-challenge explanation of how lambda calculus works, this challenge isn't standalone, and thus is unclear. \$\endgroup\$ – Mego Mar 16 '17 at 0:56