What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-08-30 03:06:01
array peremutation js recursion
const permutations = arr => { if (arr.length <= 2) return arr.length === 2 ? [arr, [arr[1], arr[0]]] : arr; return arr.reduce( (acc, item, i) => acc.concat( permutations([...arr.slice(0, i), ...arr.slice(i + 1)]).map(val =&g... Add solution -
Python 2021-08-30 00:42:02
python add commas to list
Use str. join() to make a list into a comma-separated string a_list = ["a", "b", "c"] joined_string = ",". join(a_list) Concatenate elements of `a_list` delimited by `","` print(joined_string) Add solution -
SQL 2021-08-27 16:26:02
mysql user grant database
-- Grants / privileges list SELECT * FROM information_schema.user_privileges; SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') FROM mysql.user; -- Grant a user /* ALL PRIVILEGES All privileges CREATE Create databases and tables ... Add solution -
Javascript 2021-08-26 11:02:04
lodash find duplicate element index
const _ = require('lodash'); let arr = ["a", "a", "b", "c", "c", "a"]; let result = _.omitBy( _.reduce(arr, (a, v, i) => _.set(a, v, (a[v] || []).concat([i])), {} ), v => v.length <... Add solution