Jump to content

Sort-of Y-combinator in AutoIt, possible to do better?

Recommended Posts

While AutoIt does treat function as first-class variables and can be passed/returned, it does not allow creation of anonymous function, so it is not possible to do partial application.

I could sort-of create a Y operator that takes two arguments, but that's not quite the same as sequential application:


; Local $factorial = Y(fac) ; does not work as autoit is eagerly evaluated and do not allow anonymous function definition
Local $result = Y(fac,6)


func fac($func, $num)
     return $num > 1 ? $num*$func($func,$num-1) : 1

func Y($func,$arg)
     return $func($func,$arg)


I'm wondering if it's possible to do better using Eval() or Execute(), but they are effectively just inline macros and do not allow for parameter substitution. Perhaps wrapping Eval into a string interpreter may do?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...