Notebooks 2.0 is here.

Published
Edited
Apr 7, 2021
Insert cell
Insert cell
new Set([1,2,2,3,3,3])
Insert cell
Insert cell
Insert cell
mapSet = (fn) => (set) => {
let newSet = new Set()
set.forEach(value => newSet.add(fn(value)))
return newSet
}
Insert cell
Insert cell
fn = a => a * 2
Insert cell
mapSet (fn) (new Set([1,2,2,3,3,3]))
Insert cell
Insert cell
Insert cell
mapSet2 = fn => set => {
const arrayFromSet = Array.from(set)
const mappedArray = arrayFromSet.map(fn)
return new Set(mappedArray)
}
Insert cell
Insert cell
mapSet2 (fn) (new Set([1,2,2,3,3,3,4,4,4,4]))
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more