/**
* wrap
*
* Creates a wrapper around a function and returns the wrapper as a function.
* @param $fnc.
* @return function.
* Credit:
* http://www.andyhsoftware.co.uk/space
* http://www.thescripts.com/forum/thread9037.html
* Example usage:
* function times($a,$b){
*$a * $b;
* }
* $dbl = wrap('times',2);
* echo '450 doubled is ' . $dbl(456);
*/
function fnc_wrap($fnc) {
$args = func_get_args();
array_shift($args);
$lambda = sprintf(
'$args = func_get_args(); ' .
'return call_user_func_array(\'%s\', array_merge(unserialize(\'%s\'),$args));',$fnc, serialize($args));
return create_function('', $lambda);
}
PHP and javascript snippets you can copy and paste.
Showing posts with label curry. Show all posts
Showing posts with label curry. Show all posts
Subscribe to:
Posts (Atom)
Blog Archive
-
▼
2007
(71)
-
▼
June
(20)
- js_move_elementToYPos(element, yPoint)
- js_move_elementToXPos(element, xPoint)
- js_move_elementHorizontal(element, shiftHoriz)
- js_move_elementVertical(element, shiftVertical)
- js_get_rand(max)
- js_get_isEven(n)
- js_is_odd(n)
- js_get_screenCenterY()
- js_get_screenCenterX()
- js_get_elementTop()
- js_get_elementLeft()
- js_get_elementHeight()
- js_get_elementWidth
- js_get_pageWidth()
- js_get_pageHeight()
- js_get_scrollTop()
- js_get_scrollLeft()
- js_get_browserInnerHeight
- js_get_browserInnerWidth
- js_get_pageInnerWidth
-
▼
June
(20)