Slice & Splice
Share
Explore

icon picker
Slice & Splice

Formulas: Slice() and Splice()
Category: Collections
chainsaw.svg

Slice()
Extracts a selected portion of a list
or stated otherwise...
Hey Coda, here’s a list for you. Now, I want you to slice out only part of the list, starting here and ending here.

split-files.svg

Splice()
Removes and adds values to a list
put a bit simpler...
Hey Coda, Im going to give you a list, but I want to change it a bit. Sometimes I want to add values, and sometimes delete them. Oh! Can I also specify where in that list I want you to do that?
Slice() and Splice() share some parameters while also having some of their own. For simplicity, we will look at each formula’s parameters separately.
Slice() has three parameters:
exposure-value (4).svg
Value

Slice(Value, Start, End)

A piece of text or list of values.
play (1).svg
Start

Slice(Value, Start, End)

Position in list you want to start from.
cancel (1).svg
End

Slice(Value, Start, End)

Position in list at which you want to end.

Splice() has four parameters:
exposure-value (4).svg
Value

Splice(Value, Start, DeleteCount, InsertValue)

A piece of text or a list of values.
play (1).svg
Start

Splice(Value, Start, DeleteCount, InsertValue)

Position in list you want to start from.
delete-forever.svg
DeleteCount

Splice(Value, Start, DeleteCount, InsertValue)

The number of items you want to delete.

insert-row-below.svg
InsertValue

Splice(Value, Start, DeleteCount, InsertValue)

Values, text, list you want to insert.

Slice

Slice() takes a list and allows you to get a smaller portion of that list. Just like a pizza slice is a smaller section of a whole!
List of 21 Countries:
South KoreaKuwaitCayman IslandsKazakhstanLaosLebanonSaint LuciaLiechtensteinSri LankaLiberiaLesothoLithuaniaLuxembourgLatviaLibyaMoroccoMonacoMoldovaMontenegroMadagascarMarshall Islands
Use the sliders below to return a sliced portion of the list.
Give me a sliced list starting from this position:
00
11
Give me back a total list of countries this large:
00
4
LesothoLithuaniaLuxembourgLatviaLibya
Tables are also lists! Watch how you can choose how many plants you would like to see from our below
Show me the first
00
4
plants from the database
Poison Oak
Pacific Trillium
Lemon Balm
Deer Fern

Splice

Only one letter away from Slice(), but the P makes a world of difference. Splice() allows you to manipulate lists by...
Inserting new values into a list.
Optionally deleting values from a list.
Try modifying the list of 11 words below by inserting a word of your choice and deleting any number of items as well:
I want to insert the word:
I want to place it in this position:
00
4
I also want to delete this amount of items after that:
0
0
Modify my list!
Original List
Modified List
1
tacomenucatcodaburritocomputerdatabaselistkeymusiccoffee
tacomenucatcodaburritocomputerdatabaselistkeymusiccoffee
There are no rows in this table

Done
Filter a table so it only shows rows with the largest number of votes
Done
Done

Ready to master Coda yourself?

Share
 
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.