1
0
Fork 0
mirror of https://github.com/Reuh/anselme.git synced 2025-10-27 16:49:31 +00:00

Add name and value pair methods

This commit is contained in:
Étienne Fildadut 2021-04-25 18:46:22 +02:00
parent 151c70ed26
commit b93061143c
2 changed files with 23 additions and 0 deletions

View file

@ -733,6 +733,12 @@ This only works on strings:
#### Built-in functions
##### Pair methods
`name(pair)`: returns the name (first element) of a pair
`value(pair)`: returns the value (second element) of a pair
##### List methods
`len(list)`: returns length of the list

View file

@ -267,6 +267,23 @@ functions = {
end
}
},
-- pair methods
name = {
{
arity = 1, types = { "pair" }, mode = "raw",
value = function(a)
return a.value[1]
end
}
},
value = {
{
arity = 1, types = { "pair" }, mode = "raw",
value = function(a)
return a.value[2]
end
}
},
-- list methods
len = {
{