Przeglądaj źródła

Got started with `Array` object

tcheukueppo 2 lat temu
rodzic
commit
3c52f7e7a5

+ 3 - 3
docs/maat_dev_ref/maat.md

@@ -5,7 +5,7 @@ inspired from the lovely `Perl`, `Raku` and `Lua` programming languages.
 
 - Functional Programing
 - Object Oriented Programming
-- Work and Concurrency
+- Work and Maroutines
 - Traits
 - Multiple Dispatching
 - Type Checks
@@ -32,7 +32,7 @@ inspired from the lovely `Perl`, `Raku` and `Lua` programming languages.
 - `+`: (b) absolute
 - `~`: (b) binary complement
 - `…` or `...`: (b) untight operator
-- `^`: (p) `^5` return a list of element i.e `0` to `5`
+- `^`: (p) `^5` return an array of element i.e `0` to `5`
 - `√`: (p) sqaure root operator
 - `⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹`: (b) super-script power operators
 
@@ -151,7 +151,7 @@ The pair delimiters below are used in declararing enums, arrays, hashes and on t
 var a = w|one two three|
 
 -- [ "Three", "Two", "One" ]
-var b = a.map{.capitalize}.reverse
+var b = a.map(.cap).reverse
 
 -- [ "0ne", "tw0", "three" ]
 a =~ s<o>«0»

+ 30 - 0
docs/maat_dev_ref/objects/Array.md

@@ -0,0 +1,30 @@
+# Array
+
+`Maat` has a very tiny type system with the `Array` type inheriting directly from the `Any` type.
+
+## Declaration
+
+```
+-- Yep, we have multiple ways of declaring an Array object
+var a = a<liza madjou monthe>
+var b = ["kueppo", "cyrus", "christ"]
+var c = Array.new(2, 3, "four", a<5 6>)
+
+.say for a.lmap(.split) -- a{l i z a m a d j o u m o n t h e}
+.say for a.map(.split) -- a{l i z a}, a{m a d j o u}, a{m o n t h e}
+```
+
+## Methods
+
+(**Note that parenthesis are Always optional in method calls**)
+
+Let `a` be a variable containing an object of type `Array`, `a` has the following
+methods:
+
+- `a.len() -> Num`: Return the number of elements in `a`.
+- `a.pop([ Any n ]) -> Any | Array`: If `n` is omitted, pop last element from `a` and return it else pop `n` elements from it and return them in an Array. Fail if array is emty.
+- `a.push(Any x [, Any y, ... ]) -> Array`: Push into `a` elements passed as arguments to `push` into `a`. return the modified array.
+- `a.append(Any x [, Any y, ... ]) -> Array`: Same as `push` except that it flattens arrays to append them invidually instead of appending as a single unit. Return the modified array.
+- `a.map()`:
+- `a.lmap()`:
+- `a.grep()`:

+ 0 - 0
docs/maat_dev_ref/objects/Bag.md


+ 0 - 0
docs/maat_dev_ref/objects/Bool.md


+ 0 - 0
docs/maat_dev_ref/objects/Map.md


+ 0 - 0
docs/maat_dev_ref/objects/Set.md


+ 1 - 1
docs/maat_dev_ref/objects/String.md → docs/maat_dev_ref/objects/Str.md

@@ -1,4 +1,4 @@
-## String
+# String
 
 Let `s` be a variable whose content is a object of type `String`, `s` of type
 `String` supports the following public methods: