Higher Order PHP: Map and Functional Extension Helper |
[eluser]Jamongkad[/eluser]
[quote author="xwero" date="1221050206"]Jamongkad i think you have to come up with an examples where it's easier to use your library/helper than using 'plain' php. I think the display_users example is a bad one because you retrieve too much data from the db and you are putting display logic in the controller. For the numbers example, why would an array with a value 7 return 100?? It has no other use than to show the adding of a conditional argument at runtime.[/quote] Perhaps you're right. I usually don't place display logic in the controller. Truth be known I like to place it in the models where I believe it belongs. Now about the 7 returning the 100. I just wanted to demonstrate the use of Higher Order functions. Combining the first procedure with another procedure at it's argument. One can demonstrate power and expressive of functional programming concepts using PHP. If you take a look at the Wikipedia link you can see the Python example returns the exact value. Granted yes there is nothing wrong using plain PHP. But my background in MzScheme has prompted me to write a library that could more or less emulate behavior that is present in the language. Is the the correct approach? To some it may be a bit confusing especially if you're used to doing things procedurally as opposed to using the FP approach. |
Welcome Guest, Not a member yet? Register Sign In |