Skip to content

Commit

Permalink
Merge branch '1.12.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
odino committed Mar 30, 2020
2 parents ba4331c + 4bb2074 commit 3ddbae2
Show file tree
Hide file tree
Showing 20 changed files with 1,601 additions and 307 deletions.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.12.0
Binary file modified docs/abs.wasm
Binary file not shown.
7 changes: 2 additions & 5 deletions docs/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,13 @@ if [ "${MACHINE_TYPE}" = 'x86_64' ]; then
ARCH="amd64"
fi

VERSION=1.11.4

echo "Trying to detect the details of your architecture."
echo ""
echo "If these don't seem correct, head over to https://github.com/abs-lang/abs/releases"
echo "and download the right binary for your architecture."
echo ""
echo "OS: ${OS}"
echo "ARCH: ${ARCH}"
echo "VERSION: ${VERSION}"
echo ""
echo "Are these correct? [y/N]"

Expand All @@ -50,8 +47,8 @@ do
exit 1
done < "/dev/stdin"

BIN=abs-${VERSION}-${OS}-${ARCH}
wget https://github.com/abs-lang/abs/releases/download/${VERSION}/${BIN} -O ./abs
BIN=abs-${OS}-${ARCH}
wget https://github.com/abs-lang/abs/releases/latest/download/${BIN} -O ./abs
chmod +x ./abs

echo "ABS installation completed!"
Expand Down
2 changes: 1 addition & 1 deletion docs/misc/3pl.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ another file is specified:

```
$ ~/projects/abs/builds/abs
Hello alex, welcome to the ABS (1.11.4) programming language!
Hello alex, welcome to the ABS programming language!
Type 'quit' when you're done, 'help' if you get lost!
⧐ require("abs-sample-module")
Expand Down
4 changes: 0 additions & 4 deletions docs/misc/technical-details.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,6 @@ ERROR: type mismatch: NULL + NUMBER
[78:8] h["g"] += 1
```

## Roadmap

We're currently working on [1.8](https://github.com/abs-lang/abs/milestone/15).

## Next

That's about it for this section!
Expand Down
164 changes: 145 additions & 19 deletions docs/types/array.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,27 @@ Checks whether `e` is present in the array. `e` can only be
a string or number and the array needs to be a homogeneous array
of strings or numbers:
``` bash
``` py
[1, 2, 3].contains(3) # true
[1, 2, 3].contains(4) # false
```
### chunk(size)
Splits the array into chunks of the given size:
```py
[1, 2, 3].chunk(2) # [[1, 2], [3]]
[1, 2, 3].chunk(10) # [[1,2,3]]
[1, 2, 3].chunk(1.2) # argument to chunk must be a positive integer, got '1.2'
```
### every(f)
Returns true when all elements in the array
return `true` when applied to the function `f`:
``` bash
``` py
[0, 1, 2].every(f(x){type(x) == "NUMBER"}) # true
[0, 1, 2].every(f(x){x == 0}) # false
```
Expand All @@ -161,31 +171,38 @@ return `true` when applied to the function `f`:
Returns a new array with only the elements that returned
`true` when applied to the function `f`:
``` bash
``` py
["hello", 0, 1, 2].filter(f(x){type(x) == "NUMBER"}) # [0, 1, 2]
```
### find(f)
Returns the first element that returns `true` when applied to the function `f`:
``` bash
``` py
["hello", 0, 1, 2].find(f(x){type(x) == "NUMBER"}) # 0
```
A shorthand syntax supports passing a hash and comparing
elements to the given hash:
```py
[null, {"key": "val", "test": 123}].find({"key": "val"}) # {"key": "val", "test": 123}
```
### len()
Returns the length of the array:
``` bash
``` py
[1, 2].len() # 2
```
### join(separator)
Joins the elements of the array by `separator`, defaulting to an empty string:
``` bash
``` py
[1, 2, 3].join("_") # "1_2_3"
[1, 2, 3].join() # "123"
```
Expand All @@ -194,23 +211,23 @@ Joins the elements of the array by `separator`, defaulting to an empty string:
Returns an array of the keys in the original array:
``` bash
``` py
(1..2).keys() # [0, 1]
```
### map(f)
Modifies the array by applying the function `f` to all its elements:
``` bash
``` py
[0, 1, 2].map(f(x){x+1}) # [1, 2, 3]
```
### pop()
Pops the last element from the array, returning it:
``` bash
``` py
a = [1, 2, 3]
a.shift() # 3
a # [1, 2]
Expand All @@ -220,29 +237,29 @@ a # [1, 2]
Pushes an element at the end of the array:
``` bash
``` py
[1, 2].push(3) # [1, 2, 3]
```
This is equivalent to summing 2 arrays:
``` bash
``` py
[1, 2] + [3] # [1, 2, 3]
```
### reverse()
Reverses the order of the elements in the array:
``` bash
``` py
[1, 2].reverse() # [2, 1]
```
### shift(start, end)
Removes the first elements from the array, and returns it:
``` bash
``` py
a = [1, 2, 3]
a.shift() # 1
a # [2, 3]
Expand All @@ -252,7 +269,7 @@ a # [2, 3]
Returns a portion of the array, from `start` to `end`:
``` bash
``` py
(1..10).slice(0, 3) # [1, 2, 3]"
```
Expand All @@ -268,7 +285,7 @@ back as many characters as the value of `start`:
Returns true when at least one of the elements in the array
returns `true` when applied to the function `f`:
``` bash
``` py
[0, 1, 2].map(f(x){x == 1}) # true
[0, 1, 2].map(f(x){x == 4}) # false
```
Expand All @@ -278,7 +295,7 @@ returns `true` when applied to the function `f`:
Sorts the array. Only supported on arrays of only numbers
or only strings:
``` bash
```py
[3, 1, 2].sort() # [1, 2, 3]
["b", "a", "c"].sort() # ["a", "b", "c"]
```
Expand All @@ -287,15 +304,15 @@ or only strings:
Returns the string representation of the array:
``` bash
```py
[1, 2].str() # "[1, 2]"
```
### sum()
Sums the elements of the array. Only supported on arrays of numbers:
``` bash
```py
[1, 1, 1].sum() # 3
```
Expand Down Expand Up @@ -344,10 +361,119 @@ James Harden null null
Returns an array with unique values:
``` bash
```py
[1, 1, 1, 2].unique() # [1, 2]
```
### intersect(array)
Computes the intersection between 2 arrays:
```py
[1, 2, 3].intersect([]) # []
[1, 2, 3].intersect([3]) # [3]
[1, 2, 3].intersect([3, 1]) # [1, 3]
[1, 2, 3].intersect([1, 2, 3, 4]) # [1, 2, 3]
```
### diff(array)
Computes the difference between 2 arrays,
returning elements that are only on the first array:
```py
[1, 2, 3].diff([]) # [1, 2, 3]
[1, 2, 3].diff([3]) # [1, 2]
[1, 2, 3].diff([3, 1]) # [2]
[1, 2, 3].diff([1, 2, 3, 4]) # []
```
For symmetric difference see [diff_symmetric(...)](#diff_symmetricarray)
### diff_symmetric(array)
Computes the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
between 2 arrays (elements that are only on either of the 2):
```py
[1, 2, 3].diff([]) # [1, 2, 3]
[1, 2, 3].diff([3]) # [1, 2]
[1, 2, 3].diff([3, 1]) # [2]
[1, 2, 3].diff([1, 2, 3, 4]) # [4]
```
### union(array)
Computes the [union](https://en.wikipedia.org/wiki/Union_(set_theory))
between 2 arrays:
```py
[1, 2, 3].union([1, 2, 3, 4]) # [1, 2, 3, 4]
[1, 2, 3].union([3]) # [1, 2, 3]
[].union([3, 1]) # [3, 1]
[1, 2].union([3, 4]) # [1, 2, 3, 4]
```
### flatten()
Flattens an array a single level deep:
```py
[[1, 2], 3, [4]].flatten() # [1, 2, 3, 4]
[[1, 2, 3, 4]].flatten() # [1, 2, 3, 4]
```
### flatten_deep()
Flattens an array recursively until no member is an array:
```py
[[[1, 2], [[[[3]]]], [4]]].flatten_deep() # [1, 2, 3, 4]
[[1, [2, 3], 4]].flatten_deep() # [1, 2, 3, 4]
```
### max()
Finds the highest number in an array:
```py
[].max() # NULL
[0, 5, -10, 100].max() # 100
```
### min()
Finds the lowest number in an array:
```py
[].min() # NULL
[0, 5, -10, 100].min() # -10
```
### reduce(fn, accumulator)
Reduces the array to a value by iterating through its elements and applying `fn` to them:
```py
[1, 2, 3, 4].reduce(f(value, element) { return value + element }, 0) # 10
[1, 2, 3, 4].reduce(f(value, element) { return value + element }, 10) # 20
```
### partition(fn)
Partitions the array by applying `fn` to all of its elements
and using the result of the function invocation as the key to partition by:
```py
f odd(n) {
return !!(n % 2)
}
[0, 1, 2, 3, 4, 5].partition(odd) # [[0, 2, 4], [1, 3, 5]]
[1, "1", {}].partition(str) # [[1, "1"], [{}]]
```
## Next
That's about it for this section!
Expand Down
2 changes: 1 addition & 1 deletion docs/types/builtin-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ $ cat ~/.absrc
source("~/abs/lib/library.abs")
$ abs
Hello user, welcome to the ABS (1.11.4) programming language!
Hello user, welcome to the ABS programming language!
Type 'quit' when you are done, 'help' if you get lost!
⧐ adder(1, 2)
3
Expand Down
21 changes: 21 additions & 0 deletions docs/types/number.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ by default:
10.333.round(1) # 10.3
```

### between(min, max)

Checks whether the number is between `min` and `max`:

``` bash
10.between(0, 100) # true
10.between(10, 100) # true
10.between(11, 100) # false
```

### ceil()

Rounds the number up to the closest integer:
Expand All @@ -92,6 +102,17 @@ Rounds the number up to the closest integer:
10.3.ceil() # 11
```

### clamp(min, max)

Clamps the number between min and max:

``` bash
10.clamp(0, 100) # 10
10.clamp(0, 5) # 5
10.clamp(50, 100) # 50
1.5.clamp(2.5, 3) # 2.5
```

### floor()

Rounds the number down to the closest integer:
Expand Down
Loading

0 comments on commit 3ddbae2

Please sign in to comment.