|
|
|
|
|
by mambodog
4079 days ago
|
|
You could improve the usability of this library (or FP in PHP in general), by implementing 'string lambdas' such as those found in Oliver Steele's Functional.js[0], which was a clever, if controversial, workaround for Javascript's lack of a concise anonymous function syntax at the time. For example function($n) use ($partial) { return $partial($n - 1) + $partial($n - 2);
could become 'partial(n - 1) + partial(n - 2)'
Compiling the string lambda to a function can be memoized with the string itself as the key (as many regex implementations do with the regex text) so each is only ever compiled once.[0] http://osteele.com/sources/javascript/functional/ |
|