Welcome Guest, Not a member yet? Register   Sign In
Higher Order PHP: Map and Functional Extension Helper
#18

[eluser]Jamongkad[/eluser]
Thank you for the input! Colin, I'm the first to tell you that the library is still undergoing changes even as we speak. I know my first example is a bit premature, my inspiration for the library comes from this link Higher Order Javascript. Although I'm the first to admit my implementation is weak compared to the examples given.

THe reason the syntax may look (weird|unintuitive) is because I'm experimenting with array_map as an alternative means of iteration as opposed to Foreach. I think I should have made my point a bit more clearer when I first posted this library. Truth be known I'm ready to release a new version of the library that concentrates on recursion in place of array_map.

Xwero, yes it's more of an enchantment at this point. But please do take in mind how the library structures complexity for you.

Code:
$this->map->proc('function') <------the function you want to work on
           ->args('arg1','arg2','arg3'.....) <----- arguments that will placed into the function parameters
           ->join('array') <----- list structure that the first function will iterate over and manipulate.

Let's not stop there...you can even apply functions as arguments to the target function you chose to work on. Anonymous functions at that!
Code:
$this->map->proc(lam('$x,$y,$z','$z($x(y)) * $z($x(y))')
           ->args(lam('$x','$x + 2'),lam('$x','$x * $x'),lam('$x','$x....'))
           ->join(array('of numbers'));
Please don't pay attention to the semantics of the above procedure. Just pay attention to the way I use it to structure data and how I use this data to work on the procedure.


Messages In This Thread
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-09-2008, 08:30 PM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 12:13 AM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 12:21 AM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 12:31 AM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 12:32 AM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 12:33 AM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 12:37 AM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 01:20 AM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 01:36 AM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 02:45 AM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 02:46 AM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 03:21 AM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 03:32 AM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 03:34 AM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 03:56 AM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 07:59 AM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 08:19 AM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 07:26 PM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 07:34 PM
Higher Order PHP: Map and Functional Extension Helper - by El Forum - 09-10-2008, 07:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB