diff options
| author | s-ol <s+removethis@s-ol.nu> | 2022-02-02 16:37:58 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2025-03-02 14:24:49 +0000 |
| commit | 8baadfc47832bbc3820e7d55adbbe5ddfaffedf3 (patch) | |
| tree | e97b316c29ed3fdce52a061fd8c205edc2613b9a /alv | |
| parent | allow ^ and % in symbols (diff) | |
| download | alive-8baadfc47832bbc3820e7d55adbbe5ddfaffedf3.tar.gz alive-8baadfc47832bbc3820e7d55adbbe5ddfaffedf3.zip | |
lib: rename math → math-simple, add vectorized math
Diffstat (limited to 'alv')
| -rw-r--r-- | alv/type.moon | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/alv/type.moon b/alv/type.moon index 4f38e02..765cab2 100644 --- a/alv/type.moon +++ b/alv/type.moon @@ -119,6 +119,12 @@ class Struct extends Type get: (key) => assert @types[key], Error 'index', "#{@} has no '#{key}' key" + --- iterate over contained keys and types + -- each iteration, returns a key and associated type + -- @treturn string key + -- @treturn Type associated type + iter_keys: => next, @types, nil + --- create a new struct type with a subset of keys. project: (keys) => types = {} @@ -161,6 +167,13 @@ class Array extends Type assert key >= 0 and key < @size, Error 'index', "index '#{key}' out of range!" @type + array_next = (i) => if i < @size then i + 1, @type + --- iterate over contained types + -- each iteration, returns a key and associated type + -- @treturn number key + -- @treturn Type associated type + iter_keys: => array_next, @, 0 + __eq: (other) => other.__class == Array and @size == other.size and @type == other.type __tostring: => "#{@type}[#{@size}]" |
