This gist discusses the implementation of Array flattening with JavaScript. It returns a single array with all of its element recursively flattened.
To Run Test
node flat_array_test.js
num evaluate(String expression) { | |
var tokens = expression.split(' '); | |
print(tokens); | |
// Stack for numbers: 'values' | |
List<num> values = []; | |
// Stack for Operators: 'ops' | |
List<String> ops = []; | |
for (var i = 0; i < tokens.length; i++) { | |
if (num.tryParse(tokens[i]) != null) { |
num evaluate(String expr) { | |
var divAndMult = | |
RegExp(r"\(?\s*(\d+(?:\.\d*)?)\s*([/*])\s*(\d+(?:\.\d*)?)\s*\)?"); | |
var addAndSub = | |
RegExp(r"\(?\s*(\d+(?:\.\d*)?)\s*([+-])\s*(\d+(?:\.\d*)?)\s*\)?"); | |
var nextInput = expr; | |
while (divAndMult.hasMatch(nextInput) || addAndSub.hasMatch(nextInput)) { | |
var first = nextInput.replaceAllMapped(divAndMult, (match) { |
name: Security audit | |
on: | |
push: | |
paths: | |
- '**/Cargo.toml' | |
- '**/Cargo.lock' | |
jobs: | |
security_audit: | |
runs-on: ubuntu-latest | |
steps: |
declare namespace cloudinary { | |
/** | |
* Creates a widget object and frame in memory, | |
* but does not display it until the open() method of | |
* the returned widget object is called. | |
*/ | |
function createUploadWidget<T extends CloudinaryEvent>( | |
uploadConfig: UploadInterface, | |
cb: (error: string, result: Event<T>) => void | |
): WidgetInterface; |
'use strict'; | |
const fs = require('fs'); | |
const path = require('path'); | |
const webpack = require('webpack'); | |
const resolve = require('resolve'); | |
const PnpWebpackPlugin = require('pnp-webpack-plugin'); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); | |
const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin'); |
function generatePalindromes(data) { | |
return data.filter(d => { | |
let c = d.replace('-', ''); | |
let first = c.slice(0, 2) === c.slice(-2).split``.reverse``.join``; | |
let second = c.slice(2, 4) === c.slice(4, 6).split``.reverse``.join``; | |
return first && second; | |
}); | |
} | |
function genDates(begin, end) { |
This gist discusses the implementation of Array flattening with JavaScript. It returns a single array with all of its element recursively flattened.
To Run Test
node flat_array_test.js