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
**`(tail a-list)`** will return the last elements of a list as a new list:
334
-
-`[] -> []`,
335
-
-`[1] -> []`,
336
-
-`[1 2 3] -> [2 3]`.
337
-
338
-
**`(head a-list)`** will return the first element of a list, or `nil` if the list is empty:
339
-
-`[] -> nil`,
340
-
-`[1] -> 1`,
341
-
-`[1 2 3] -> 1`.
342
-
343
-
**`(empty? a-list)`** returns true if the list (or string) is empty (or the value is `nil`), false otherwise.
344
-
345
-
**`(nil? a-list)`** will always return false as a list isn't nil (which is the void value, returned by `head`).
346
-
347
-
**`(@ a-list index)`** gets the element at `index` inside the list. Negative indices are supported, with `-1` being the last element.
348
-
349
-
**`(@@ a-2d-list i j)`** is equivalent to `a-2d-list[i][j]` in Python: it gets the element at position `j` in the sublist `(@ a-2d-list i)`. It's a shortcut for `(@ (@ a-2d-list i) j)`.
350
-
351
-
**`(append a-list 5)`** returns a new list with 5 added at the end,
352
-
**`(append! a-list 5)`** will add 5 in-place to a-list, without returning a new list.
353
-
354
-
**`(concat a-list [5 6])`** returns a new list with 5 and 6 added at the end,
355
-
**`(concat! a-list [5 6])`** will add 5 and 6 in-place to a-list, without returning a new list.
356
-
357
-
**`(pop a-list index)`** returns a new list without the element at `index` (supports negative indices, -1 being the end),
358
-
**`(pop! a-list index)`** will remove the element at `index` in-place, without returning a new list.
359
-
360
-
**`(@= a-list index value)`** updates `a-list` in-place by replacing the element at `index` by `value` (supports negative indices, -1 being the end).
361
-
362
-
Akin to `@=`, `@@=` can update lists in-place, but this version works on 2D list (list of lists, or list of strings). Eg **`(@@= a-2d-list i j value)`** will replace the element at `a-2d-list[i][j]` by `value`. If the sublist is a string, `value` needs to be a single char, eg `(@@= a-list-of-strings i j "b")`.
363
-
364
-
---
365
-
366
-
### Test operator
367
-
368
-
**`(assert condition message)`** will interrupt the execution if `condition` is false, and display the given message.
369
-
370
-
---
371
-
372
-
### Type operators
373
-
374
-
**`(type value)`** returns the type of the given value (or variable) as a string: `"List"`, `"Number"`, `"String"`, `"Function"`, `"CProc"`, `"Closure"`, `"UserType"`, `"Nil"`, `"Bool"`, `"Undefined"`.
375
-
376
-
**`(hasField closure "a")`** returns true if the given closure has a field named `a`, false otherwise.
0 commit comments