You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/documentation/data-structures.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,12 +17,13 @@ To create a list surround the white space separated values with parentheses or u
17
17
'(1 2 3) # use a quote to create a list
18
18
```
19
19
20
-
To access values in a list the functions `get`, `first`, `second`, `next`and `rest` can be used.
20
+
To access values in a list the functions `get`, `first`, `second`, `next`, `rest`and `peek` can be used.
21
21
22
22
```phel
23
23
(get (list 1 2 3) 0) # Evaluates to 1
24
24
(first (list 1 2 3)) # Evaluates to 1
25
25
(second (list 1 2 3)) # Evaluates to 2
26
+
(peek (list 1 2 3)) # Evaluates to 3
26
27
(next (list 1 2 3)) # Evaluates to (2 3)
27
28
(next (list)) # Evaluates to nil
28
29
(rest (list 1 2 3)) # Evaluates to (2 3)
@@ -54,12 +55,13 @@ To create a vector wrap the white space seperated values with brackets or use th
54
55
(vector 1 2 3) # Creates a new vector with three values
55
56
```
56
57
57
-
To get a value by its index use the `get` function. Similar to list you can use the `first`and `second` function to access the first or second values of the vector.
58
+
To get a value by its index use the `get` function. Similar to list you can use the `first`, `second`and `peek` function to access the first, second and last values of the vector.
58
59
59
60
```phel
60
61
(get [1 2 3] 0) # Evaluates to 1
61
62
(first [1 2 3]) # Evaluates to 1
62
63
(second [1 2 3]) # Evaluates to 2
64
+
(peek [1 2 3]) # Evaluates to 3
63
65
```
64
66
65
67
New values can be appended by using the `push` function.
0 commit comments