g.js — graphical objects for JavaScript

Lists

Lists are a fundamental construct for structured programming.

Creating lists

makeNumbers — Make a list of numbers

split — Split a string into substrings

import — Import CSV data as a list of maps

Getting items

first / second / last — Take the first, second or last item

rest — Take all but the first item

slice — Take a portion of the list

takeEvery — Take every nth element

pick — Grab random elements from the list

randomSample — Select random elements from the list

switch — Select one of the inputs

Querying lists

contains — check if a list contains the item

count — count the number of items in the list

Combining lists

combine — combine multiple lists together

Modifying the list

cull — Keep only items where the corresponding boolean is true

distinct — Remove all duplicate items

repeat — Repeat items in the list

reverse — Reverse the order of items in the list

shift — Move items from the beginning to the end

shuffle — Randomize the order of items in the list

sort — Sort items in the list

Maps / dictionaries

zipMap — Combine keys and values together in a map