Skip to content

Instantly share code, notes, and snippets.

@flaviusb
Last active December 12, 2022 07:55
Show Gist options
  • Save flaviusb/1b397f452efb2b9e6a71eb48e94b50d3 to your computer and use it in GitHub Desktop.
Save flaviusb/1b397f452efb2b9e6a71eb48e94b50d3 to your computer and use it in GitHub Desktop.
Array notes
array
q?
length {...}
ith get $n {...}
ith set $n {} {...}
ith insert $n {} {...}
ith pop $n {...}
ith remove $n {...}
slice get $n $n {...}
slice set {...} $n {...}
slice insert {...} $n {...}
slice pop $n $n {...}
slice remove $n $n {...}
concat {...}+
mk {}+
$n can be a positive or negative number, or the identifiers 'head' or 'tail'
{...} is an array if there is no q, or a quoted array if there is a q
{} is a single array element, or if q, then a quoted single array element
An array is a group with space separated array elements inside
An array element is a group with its contents inside it
Eg
{{1 + 1} {fn foo(arg: u8) -> u8 { arg + 1 }} {wefgq ewrg efg etgh e}}
is an array with three elements.
The first element is
{1 + 1}
whose content is
1 + 1
length returns the length of the array
the ith things do the thing to a single entry at the ith position
the slice things do the thing to the section of the array between the two positions
concat takes several arrays and turns them into one array
mk creates a new array based on a bunch of array elements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment