/\p{L}\p{M}?|\S|\s/gu
Usage:
"മാസങ്ങളിൽ മേടം പ്രധാനം".match(/\p{L}\p{M}?|\S|\s/gu); // ["മാ", "സ", "ങ്", "ങ", "ളി", "ൽ", " ", "മേ", "ടം", " ", "പ്", "ര", "ധാ", "നം"]
function mergeSort(input) { | |
const merge = (left, right) => { | |
const merged = []; | |
while (left.length && right.length) { | |
if (left[0] < right[0]) { | |
merged.push(left.shift()); | |
} else { | |
merged.push(right.shift()); | |
} | |
} |
/* | |
input: | |
[ | |
[01, 02, 03, 04, 05, 06], | |
[07, 08, 09, 10, 11, 12], | |
[13, 14, 15, 16, 17, 18], | |
[19, 20, 21, 22, 23, 24], | |
[25, 26, 27, 28, 29, 30], | |
[31, 32, 33, 34, 35, 36] | |
]; |
copy((function() { | |
const contentParagraphs = [ | |
...document.querySelectorAll("#main > #content > article > .entry-content > p"), | |
...document.querySelectorAll("div.entry-content > div:not(#widgets-wrap-before-post-content)") | |
]; | |
return contentParagraphs | |
.filter(x => x.getAttribute("role") !== "navigation") | |
.reduce((acc, value) => acc + "\n" + value.textContent, ""); | |
})()); |
[1, 2, 3, 4, 5].reduce((accumulator, current, index, { [index + 1]: next }) => next ? accumulator.concat(current / next) : accumulator, []); // [ 0.5, 0.6666666666666666, 0.75, 0.8 ] |
function* fibonacci(max = Number.MAX_SAFE_INTEGER) { | |
let current = 1; | |
let previous = 0; | |
while (current <= max) { | |
[current, previous] = [previous, current + previous]; | |
if (current <= max) { | |
yield current; | |
} else { | |
return; | |
} |
/\p{L}\p{M}?|\S|\s/gu
Usage:
"മാസങ്ങളിൽ മേടം പ്രധാനം".match(/\p{L}\p{M}?|\S|\s/gu); // ["മാ", "സ", "ങ്", "ങ", "ളി", "ൽ", " ", "മേ", "ടം", " ", "പ്", "ര", "ധാ", "നം"]
using System; | |
using System.Collections.Generic; | |
using System.Numerics; | |
public static class BigIntegerExtensions | |
{ | |
private static readonly char[] digits = new char[] | |
{ | |
'0', '1', '2', '3', '4', '5', '6', '7', | |
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f', |
Object.defineProperty(BigInt.prototype, "toBase62String", { | |
value: function () { | |
const base = 62n; | |
const digits = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
const sign = this < 0n ? "-" : ""; | |
let [result, quotient] = ["", sign ? 0n - this : this]; | |
do { | |
result = `${digits[Number(quotient % base)]}${result}`; | |
} while (quotient /= base); | |
return `${sign}${result}`; |
Object.defineProperty(BigInt.prototype, "toBase62String", { | |
value: function () { | |
const base = 62n; | |
const digits = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
const sign = this < 0n ? "-" : ""; | |
let [result, quotient] = ["", sign ? 0n - this : this]; | |
do { | |
result = `${digits[Number(quotient % base)]}${result}`; | |
} while (quotient /= base); | |
return `${sign}${result}`; |
Object.defineProperty(BigInt.prototype, "toBase64String", { | |
value: function () { | |
const base = 64n; | |
const digits = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ&#"; | |
const sign = this < 0n ? "-" : ""; | |
let [result, quotient] = ["", sign ? 0n - this : this]; | |
do { | |
result = `${digits[Number(quotient % base)]}${result}`; | |
} while (quotient /= base); | |
return `${sign}${result}`; |