Skip to content

Instantly share code, notes, and snippets.

@zonuexe
Created August 2, 2019 06:52
Show Gist options
  • Save zonuexe/b5faad2a02baadf32adb65bf4689d0f3 to your computer and use it in GitHub Desktop.
Save zonuexe/b5faad2a02baadf32adb65bf4689d0f3 to your computer and use it in GitHub Desktop.
Z combinator
<?php
// Short
$fix=fn($f)=>(fn($x)=>$f(fn(...$as)=>($x($x)(...$as))))(fn($x)=>$f(fn(...$as)=>($x($x)(...$as))));
// Long
$fix = fn (callable $f) => call_user_func(
(fn (callable $x) => $f(fn (...$as) => ($x($x)(...$as)))),
(fn (callable $x) => $f(fn (...$as) => ($x($x)(...$as))))
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment