This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // The slow, although default way of doing fibonacci --------------------------- | |
| function _fibs($n) | |
| { | |
| if ($n < 2) | |
| return $n; | |
| else | |
| return _fibs($n-1) + _fibs($n-2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class Synthesization { | |
| private function signatureIsGetter($signature) { | |
| if (preg_match('/^get/', $signature)) | |
| return true; | |
| return false; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // data | |
| var nums = [1, 2, 3, 4, 5, 6, 7, 8]; | |
| // What you would do if you did not have a functional mindset | |
| var evens = []; | |
| for (var i = 0; i < nums.length; ++i) { | |
| if (nums[i] % 2 === 0) { | |
| evens.push(nums[i]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function pluckWith($key, $array) { | |
| return function($value) use ($key, $array) { | |
| $matches = []; | |
| foreach ($array as $k => $v) | |
| if (array_key_exists($key, $v) && $v[$key] == $value) | |
| array_push($matches, $array[$k]); | |
| return $matches; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Library method -------------------------------------------------------------- | |
| var pluckWith = function(k, a) { | |
| return function(v) { | |
| var res = []; | |
| for (var i = 0; i < a.length; i++) | |
| if (a[i].hasOwnProperty(k) && a[i][k] === v) | |
| res.push(a[i]); | |
| return res; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="text/x-handlebars" data-template-name="sometemplate"> | |
| <script src="jquery.js"></script> | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="text/x-handlebars" data-template-name="sometemplate"> | |
| <script src="jquery.js"></script> | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="text/x-handlebars" data-template-name="sometemplate"> | |
| <script src="jquery.js"></script> | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| safeInit :: [a] -> [a] | |
| safeInit (x:xs) | |
| | null xs = [] | |
| | otherwise = x : safeInit xs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $query = new WP_Query(array( | |
| 'post_type' => 'music', | |
| 'posts_per_page' => 5 | |
| )); | |
| while($query->have_posts()) { | |
| echo "post"; | |
| } |