Skip to content

Instantly share code, notes, and snippets.

@jamierumbelow
Last active March 4, 2019 16:52
Show Gist options
  • Save jamierumbelow/220ee7eea6629765f84d6058a1139b19 to your computer and use it in GitHub Desktop.
Save jamierumbelow/220ee7eea6629765f84d6058a1139b19 to your computer and use it in GitHub Desktop.
<?php
// ltr
$curriedStrpos = curry('strpos', 'haystack');
$this->assertEquals(1, $curriedStrpos('a'));
$this->assertEquals(4, $curriedStrpos('t'));
// rtl
$curriedSubstr = curryFromRight('substr', 0, 1);
$this->assertEquals([ 'a', 'b', 'c' ],
collect([ 'anything', 'but', 'chardonnay' ])->map($curriedSubstr));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment