HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
tc39
proposal-slice-notation
HTML2018–2022
tc39 / proposal-slice-notation

proposal-slice-notation

Discover this repository through its Hacker News conversations.

5Distinct people
8Mentions
0Explicit recommenders
528GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

A public description has not been verified.

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 1:49:46 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year8 dated mentions

Observed mentions: 2018-06-29 05:15:00 UTC to 2022-07-28 20:13:31 UTC.

012342018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20182019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 4 mentions; 0 submissions, 4 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20202021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2022

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC101
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC404
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC101
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC101
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC101

What Hacker News says

8 sources
> Switch statements JS has had switch statements for a long time. Do you mean switch "expressions" that can be used inline? It's not pretty but JS has long supported that too using either eval() "hacks" or IIFEs: https://stackoverflow.com/questions/32451049/is-eval-the-onl... Do you mean pattern matching? There are two Stage 1 TC39 proposals with different approaches to it: More hands-on/direct: https://github.com/tc39/proposal-pattern-matching More indirect: https://github.com/tc39/proposal-do-expressions > list comprehensions There are several libraries with strong Iterator support today that while not syntactically gorgeous do great jobs at allowing you to write simple list operations. Off the top of my head are IxJS and iter-tools, but also classic mainstays like up to date versions of lodash and Ramda. There's a Stage 2 proposal to b
Read the rest
ring more of them into "the standard library": https://github.com/tc39/proposal-iterator-helpers There's also a Stage 2 proposal for an operator to make the syntax generally nicer no matter the library: https://github.com/tc39/proposal-pipeline-operator > array slicing Array.prototype.slice() was added back in ES2015: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... Array.prototype.at() was "just added" in ES2022 for unary (single argument) "slice" (ability to use negative indexes): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... If you prefer syntax to function calls, there's a Stage 1 proposal still live for that: https://github.com/tc39/proposal-slice-notation > better equality operators That ship has probably sailed. Most projects at this point just have linter rules to standardize everything to the more reliable "triple equals" (===, and !==). There are proposals for more structural equality functions in the standard library, though, for instance: https://github.com/tc39/proposal-array-equality
In HypeScript: Simplified TypeScript type system in TypeScript's own type system
# Permutations of a list: - haskell: perms [] = [[]] perms xs = [ x:ps | x <- xs , ps <- perms ( xs\\[x] ) ] - js: (using https://github.com/tc39/proposal-slice-notation for conciseness) const perms = xs => xs.length === 0 ? [[]] : xs.flatMap((xi, i) => perms([...xs[0:i], ...xs[i+1:]).map(xsi => [xi, ...xsi]) # Cartesian product of 2 or n lists - haskell: cart2 xs ys = [(x,y) | x <- xs, y <- ys] cartn :: [[a]] -> [[a]]; cartn [] = [[]] cartn(xs:xss) = [x:ys | x <- xs, ys <- yss] where yss = cartn xss - js: const cart2 = (xs, ys) => xs.flatMap(x => ys.map(y => [x,y])); const cartn = (...args) => args.reduce((yss, xs) => yss.flatMap(ys => xs.map(x => [...ys, x])), [[]]); // or recursive const cartn = (xs, ...xss) => xss.length === 0 ? xs : xs.flatMap(x => cartn(...xss).map(
Read the rest
y => [x,y]))
In Ask HN: What is the most beautiful piece of code you've ever read?
the a:b notation for JS is still in proposal phase https://github.com/tc39/proposal-slice-notation/pull/32, but I'll use it below to create ranges I don't understand your `+0.5`, I've written below the transcription for your description [...1:30].map(a => [...a+1:30].filter(b => gcd(a,b)==1).map(b => [...b+1:30].filter(c => gcd(a,c)==1 && gcd(b,c)==1 && Number.isInteger((a**3+b**3+c**3)**(1/3)) .map(c => [a, b, c]) ) ).flat(2) Or another equivalent way: [...1:30].flatMap(a => [...a+1:30].filter(b => gcd(a,b)==1).flatMap(b => [...b+1:30].filter(c => gcd(a,c)==1 && gcd(b,c)==1 && Number.isInteger((a**3+b**3+c**3)**(1/3))) .flatMap(c => [[a, b, c]]) Or another way (generating first all the triples): [...1:30].flatMap(a => [...a+
Read the rest
1:30].flatMap(b => [...b+1:30].flatMap(c => [[a, b, c]]))) .filter(([a, b, c]) => gcd(a,b)==1 && gcd(a,c)==1 && gcd(b,c)==1 && Number.isInteger((a**3+b**3+c**3)**(1/3))) with https://github.com/tc39/proposal-iterator-helpers, which would allow lazy evaluation, and make more sense than above (1:30).flatMap(a => (a+1:30).flatMap(b => (b+1:30).flatMap(c => [[a, b, c]]))) .filter(([a, b, c]) => gcd(a,b)==1 && gcd(a,c)==1 && gcd(b,c)==1 && Number.isInteger((a**3+b**3+c**3)**(1/3))) without the slice-notation, it's really ugly (hence the proposal in the first link) Array.from({length: 30},(_,a)=>a+1) .flatMap(a=>Array.from({length: 30-a-1},(_,b)=>a+b+1) .flatMap(b => Array.from({length: 30-b-1},(_,c)=>b+c+1).flatMap(c => [[a, b, c]]))) .filter(([a, b, c]) => gcd(a,b)==1 && gcd(a,c)==1 && gcd(b,c)==1 && Number.isInteger((a**3+b**3+c**3)**(1/3)))
In List comprehensions across languages (2007)

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.