This file contains 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
/* Final Refactor */ | |
// This is the final form of the function. I included the first iteration below to show my thought process as well as how the code was refactored | |
function flatten (arr) { | |
if (!Array.isArray(arr)) return -1; | |
return arr.reduce((p, c) => !Array.isArray(c) ? p.concat(c) : p.concat(flatten(c)), []); | |
} | |
/* End Final Refactor */ | |
/* First Iteration - With Comments */ |
This file contains 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
/* This function will flatten an array of arbitrarily nested | |
arrays of integers into a flat array of integers | |
it returns an array of flattened items | |
SETUP INSTRUCTIONS | |
make sure you have nodejs >= V6.0 installed | |
in your terminal make a new folder with mkdir flatten | |
navigate to the newly created folder with cd flatten | |
make a new file with touch index.js | |
install mocha and chai using npm install mocha chai |
This file contains 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
this_dir = File.dirname(__FILE__) + "/" | |
require this_dir + "vagrant/hostmaster.rb" | |
Vagrant::Config.run do |config| | |
# define some colors for our output | |
def colorize(text, color_code) "#{color_code}#{text}\033[0m" end |
This file contains 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 | |
namespace My\Custom\Doctrine2\Function; | |
/** | |
* RandFunction ::= "RAND" "(" ")" | |
*/ | |
class Rand extends FunctionNode | |
{ | |
public function parse(\Doctrine\ORM\Query\Parser $parser) |