Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
bbf5976
new math function sqrt_is
francolq Sep 8, 2023
52eb39f
rename sqrt_is to is_sqrt and fix format
francolq Sep 11, 2023
2725b16
bump version to 1.7.0 to match release
MicroProofs Mar 2, 2024
fc3b9d5
Add disclaimer on bytearray.to_string
KtorZ Mar 14, 2024
b57389f
Also add disclaimer on string.from_bytearray
KtorZ Mar 14, 2024
65a63d8
Add value.reduce into transaction/value.ak
micahkendall Mar 15, 2024
229f3ce
Update value.ak
micahkendall Mar 15, 2024
3a8e77c
requested changes
micahkendall Mar 15, 2024
3e47bb8
bump CI version
micahkendall Mar 15, 2024
d8dcf4e
fmt other
micahkendall Mar 15, 2024
28d1268
fmt older aiken
micahkendall Mar 15, 2024
5edf422
Update lib/aiken/transaction/value.ak
micahkendall Mar 15, 2024
f0d151a
Update lib/aiken/transaction/value.ak
micahkendall Mar 15, 2024
28c935d
Update lib/aiken/transaction/value.ak
micahkendall Mar 15, 2024
852b524
Update lib/aiken/transaction/value.ak
micahkendall Mar 15, 2024
79e368f
Update lib/aiken/transaction/value.ak
micahkendall Mar 15, 2024
85bb70a
redundant test case change
micahkendall Mar 15, 2024
28e0ead
remove dict changes
micahkendall Mar 15, 2024
e5fde44
Merge pull request #84 from aiken-lang/micah/value_reduce
KtorZ Mar 15, 2024
eb39cdd
Merge pull request #73 from francolq/patch-1
KtorZ Mar 22, 2024
871338c
feat: Add from asset list to stdlib
MicroProofs Mar 22, 2024
e475816
update aiken version
MicroProofs Mar 24, 2024
d9655fc
fix formatting and update workflow version
MicroProofs Mar 27, 2024
7795b24
Add explainer to from_asset_list and one extra test
KtorZ Mar 28, 2024
c074d34
Fill-in CHANGELOG for 1.8.0
KtorZ Mar 28, 2024
be93039
Fix link in string.from_bytearray disclaimer.
KtorZ Mar 28, 2024
f02446f
Specialize Dict's key to ByteArray
KtorZ Jan 14, 2024
2df2aa8
Replace occurences of 2-tuples with pairs
KtorZ Apr 18, 2024
577a586
Define aiken/map interface for Map<key, value>
MicroProofs Apr 29, 2024
c441994
Rename Map to AList
MicroProofs May 2, 2024
ccb2e27
missed 2 more places
MicroProofs May 2, 2024
d962dca
rename function
MicroProofs May 2, 2024
0ae9197
finish renaming to alist
MicroProofs May 4, 2024
c5f1994
Merge pull request #81 from aiken-lang/specialize-dict-key
MicroProofs May 4, 2024
87be7c0
fmt fix
MicroProofs May 4, 2024
d2f1966
Rework doc for alist, rename some functions and fill-in CHANGELOG
KtorZ May 10, 2024
fba13a5
Update value.ak
dmitrystas May 22, 2024
d5a5d6f
Merge pull request #87 from dmitrystas/main
KtorZ May 22, 2024
5a279d8
Closes #82.
KtorZ May 22, 2024
b281d4c
Rename AList -> Pairs
KtorZ May 23, 2024
cfcf2bf
fix formatting issue
MicroProofs May 23, 2024
c94606a
new ci version of aiken
MicroProofs May 24, 2024
93f1705
Bump setup-aiken.
KtorZ May 24, 2024
de654c4
Add small 'compatibility matrix' on README.
KtorZ May 24, 2024
b83d3c3
Bump version to 1.9.0
KtorZ May 24, 2024
18a6305
Fix documentation examples on pairs.
KtorZ May 24, 2024
0407b3a
Update stdlib's compatibility matrix.
KtorZ Jun 6, 2024
5fc33fb
catch up the v3 branch
logicalmechanism Jun 24, 2024
1522f63
split scriptpurpose into scriptinfo, update names, and change scriptc…
logicalmechanism Jun 24, 2024
8ae154a
merge this up into the v3 branch
logicalmechanism Jun 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
finish renaming to alist
  • Loading branch information
MicroProofs committed May 4, 2024
commit 0ae9197ccdc253cfab9562eacc58403a871c0196
120 changes: 60 additions & 60 deletions lib/aiken/alist.ak
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
/// Duplicate keys are not removed. Only the **first** key found is removed.
///
/// ```aiken
/// map.remove_first([], "a") == []
/// map.remove_first([Pair("a", 1)], "a") == []
/// map.remove_first([Pair("a", 1), Pair("b", 2)], "a") == [Pair("b", 2)]
/// map.remove_first([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == [Pair("b", 2), Pair("a", 3)]
/// alist.remove_first([], "a") == []
/// alist.remove_first([Pair("a", 1)], "a") == []
/// alist.remove_first([Pair("a", 1), Pair("b", 2)], "a") == [Pair("b", 2)]
/// alist.remove_first([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == [Pair("b", 2), Pair("a", 3)]
/// ```
pub fn remove_first(self: AList<key, value>, key k: key) -> AList<key, value> {
when self is {
Expand Down Expand Up @@ -49,10 +49,10 @@ test remove_first_4() {
/// Duplicate keys are not removed. Only the **last** key found is removed.
///
/// ```aiken
/// map.remove_last([], "a") == []
/// map.remove_last([Pair("a", 1)], "a") == []
/// map.remove_last([Pair("a", 1), Pair("b", 2)], "a") == [Pair("b", 2)]
/// map.remove_last([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == [Pair("a", 1), Pair("b", 2)]
/// alist.remove_last([], "a") == []
/// alist.remove_last([Pair("a", 1)], "a") == []
/// alist.remove_last([Pair("a", 1), Pair("b", 2)], "a") == [Pair("b", 2)]
/// alist.remove_last([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == [Pair("a", 1), Pair("b", 2)]
/// ```
pub fn remove_last(self: AList<key, value>, key k: key) -> AList<key, value> {
when self is {
Expand Down Expand Up @@ -95,10 +95,10 @@ test remove_last_4() {
/// Remove all key-value pairs matching the key from the AList. If the key is not found, no changes are made.
///
/// ```aiken
/// map.remove_all([], "a") == []
/// map.remove_all([Pair("a", 1)], "a") == []
/// map.remove_all([Pair("a", 1), Pair("b", 2)], "a") == [Pair("b", 2)]
/// map.remove_all([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == [Pair("b", 2)]
/// alist.remove_all([], "a") == []
/// alist.remove_all([Pair("a", 1)], "a") == []
/// alist.remove_all([Pair("a", 1), Pair("b", 2)], "a") == [Pair("b", 2)]
/// alist.remove_all([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == [Pair("b", 2)]
/// ```
pub fn remove_all(self: AList<key, value>, key k: key) -> AList<key, value> {
when self is {
Expand Down Expand Up @@ -133,13 +133,13 @@ test remove_all_4() {
remove_all(fixture, "a") == [Pair("b", 2)]
}

/// Finds the first key in the map associated with a given value, if any.
/// Finds the first key in the alist associated with a given value, if any.
///
/// ```aiken
/// map.find_first([], 1) == None
/// map.find_first([Pair("a", 1)], 1) == Some("a")
/// map.find_first([Pair("a", 1), Pair("b", 2)], 1) == Some("a")
/// map.find_first([Pair("a", 1), Pair("b", 2), Pair("c", 1)], 1) == Some("a")
/// alist.find_first([], 1) == None
/// alist.find_first([Pair("a", 1)], 1) == Some("a")
/// alist.find_first([Pair("a", 1), Pair("b", 2)], 1) == Some("a")
/// alist.find_first([Pair("a", 1), Pair("b", 2), Pair("c", 1)], 1) == Some("a")
/// ```
pub fn find_first(self: AList<key, value>, v: value) -> Option<key> {
when self is {
Expand Down Expand Up @@ -169,13 +169,13 @@ test find_first_4() {
find_first([Pair("a", 14), Pair("b", 42), Pair("c", 14)], 14) == Some("a")
}

/// Finds the last key in the map associated with a given value, if any.
/// Finds the last key in the alist associated with a given value, if any.
///
/// ```aiken
/// map.find_last([], 1) == None
/// map.find_last([Pair("a", 1)], 1) == Some("a")
/// map.find_last([Pair("a", 1), Pair("b", 2)], 1) == Some("a")
/// map.find_last([Pair("a", 1), Pair("b", 2), Pair("c", 1)], 1) == Some("c")
/// alist.find_last([], 1) == None
/// alist.find_last([Pair("a", 1)], 1) == Some("a")
/// alist.find_last([Pair("a", 1), Pair("b", 2)], 1) == Some("a")
/// alist.find_last([Pair("a", 1), Pair("b", 2), Pair("c", 1)], 1) == Some("c")
/// ```
pub fn find_last(self: AList<key, value>, v: value) -> Option<key> {
when self is {
Expand Down Expand Up @@ -208,13 +208,13 @@ test find_last_4() {
find_last([Pair("a", 14), Pair("b", 42), Pair("c", 14)], 14) == Some("c")
}

/// Finds all keys in the map associated with a given value.
/// Finds all keys in the alist associated with a given value.
///
/// ```aiken
/// map.find_all([], 1) == []
/// map.find_all([Pair("a", 1)], 1) == ["a"]
/// map.find_all([Pair("a", 1), Pair("b", 2)], 1) == ["a"]
/// map.find_all([Pair("a", 1), Pair("b", 2), Pair("c", 1)], 1) == ["a", "c"]
/// alist.find_all([], 1) == []
/// alist.find_all([Pair("a", 1)], 1) == ["a"]
/// alist.find_all([Pair("a", 1), Pair("b", 2)], 1) == ["a"]
/// alist.find_all([Pair("a", 1), Pair("b", 2), Pair("c", 1)], 1) == ["a", "c"]
/// ```
pub fn find_all(self: AList<key, value>, v: value) -> List<key> {
when self is {
Expand Down Expand Up @@ -255,7 +255,7 @@ test find_all_4() {
/// Pair(3, 300),
/// ]
///
/// map.foldr(fixture, 0, fn(k, v, result) { k * v + result }) == 1400
/// alist.foldr(fixture, 0, fn(k, v, result) { k * v + result }) == 1400
/// ```
pub fn foldr(
self: AList<key, value>,
Expand Down Expand Up @@ -287,7 +287,7 @@ test foldr_3() {
foldr(fixture, 0, fn(k, v, result) { k * v + result }) == 1400
}

/// Fold over the key-value pairs in a map. The fold direction follows keys
/// Fold over the key-value pairs in a alist. The fold direction follows keys
/// in ascending order and is done from left-to-right.
///
/// ```aiken
Expand All @@ -297,7 +297,7 @@ test foldr_3() {
/// Pair(3, 300),
/// ]
///
/// map.foldl(fixture, 0, fn(k, v, result) { k * v + result }) == 1400
/// alist.foldl(fixture, 0, fn(k, v, result) { k * v + result }) == 1400
/// ```
pub fn foldl(
self: AList<key, value>,
Expand All @@ -322,14 +322,14 @@ test foldl_2() {
) == 56
}

/// Get the value in the map by its key.
/// Get the value in the alist by its key.
/// If multiple values with the same key exist, only the first one is returned.
///
/// ```aiken
/// map.get_first([], "a") == None
/// map.get_first([Pair("a", 1)], "a") == Some(1)
/// map.get_first([Pair("a", 1), Pair("b", 2)], "a") == Some(1)
/// map.get_first([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == Some(1)
/// alist.get_first([], "a") == None
/// alist.get_first([Pair("a", 1)], "a") == Some(1)
/// alist.get_first([Pair("a", 1), Pair("b", 2)], "a") == Some(1)
/// alist.get_first([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == Some(1)
/// ```
pub fn get_first(self: AList<key, value>, key k: key) -> Option<value> {
when self is {
Expand Down Expand Up @@ -363,14 +363,14 @@ test get_first_5() {
get_first([Pair("a", 1), Pair("b", 2), Pair("c", 3)], "d") == None
}

/// Get the value in the map by its key.
/// Get the value in the alist by its key.
/// If multiple values with the same key exist, only the last one is returned.
///
/// ```aiken
/// map.get_last([], "a") == None
/// map.get_last([Pair("a", 1)], "a") == Some(1)
/// map.get_last([Pair("a", 1), Pair("b", 2)], "a") == Some(1)
/// map.get_last([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == Some(3)
/// alist.get_last([], "a") == None
/// alist.get_last([Pair("a", 1)], "a") == Some(1)
/// alist.get_last([Pair("a", 1), Pair("b", 2)], "a") == Some(1)
/// alist.get_last([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == Some(3)
/// ```
pub fn get_last(self: AList<key, value>, key k: key) -> Option<value> {
when self is {
Expand Down Expand Up @@ -407,13 +407,13 @@ test get_last_5() {
get_last([Pair("a", 1), Pair("b", 2), Pair("c", 3)], "d") == None
}

/// Get all values in the map associated with a given key.
/// Get all values in the alist associated with a given key.
///
/// ```aiken
/// map.get_all([], "a") == []
/// map.get_all([Pair("a", 1)], "a") == [1]
/// map.get_all([Pair("a", 1), Pair("b", 2)], "a") == [1]
/// map.get_all([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == [1, 3]
/// alist.get_all([], "a") == []
/// alist.get_all([Pair("a", 1)], "a") == [1]
/// alist.get_all([Pair("a", 1), Pair("b", 2)], "a") == [1]
/// alist.get_all([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == [1, 3]
/// ```
pub fn get_all(self: AList<key, value>, key k: key) -> List<value> {
when self is {
Expand Down Expand Up @@ -448,13 +448,13 @@ test get_all_5() {
get_all([Pair("a", 1), Pair("b", 2), Pair("c", 3)], "d") == []
}

/// Check if a key exists in the map.
/// Check if a key exists in the alist.
///
/// ```aiken
/// map.has_key([], "a") == False
/// map.has_key([Pair("a", 1)], "a") == True
/// map.has_key([Pair("a", 1), Pair("b", 2)], "a") == True
/// map.has_key([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == True
/// alist.has_key([], "a") == False
/// alist.has_key([Pair("a", 1)], "a") == True
/// alist.has_key([Pair("a", 1), Pair("b", 2)], "a") == True
/// alist.has_key([Pair("a", 1), Pair("b", 2), Pair("a", 3)], "a") == True
/// ```
pub fn has_key(self: AList<key, value>, k: key) -> Bool {
when self is {
Expand Down Expand Up @@ -487,10 +487,10 @@ test has_key_5() {
/// Extract all the keys present in a given `AList`.
///
/// ```aiken
/// map.keys([]) == []
/// map.keys([Pair("a", 1)]) == ["a"]
/// map.keys([Pair("a", 1), Pair("b", 2)]) == ["a", "b"]
/// map.keys([Pair("a", 1), Pair("b", 2), Pair("a", 3)]) == ["a", "b", "a"]
/// alist.keys([]) == []
/// alist.keys([Pair("a", 1)]) == ["a"]
/// alist.keys([Pair("a", 1), Pair("b", 2)]) == ["a", "b"]
/// alist.keys([Pair("a", 1), Pair("b", 2), Pair("a", 3)]) == ["a", "b", "a"]
/// ```
pub fn keys(self: AList<key, value>) -> List<key> {
when self is {
Expand All @@ -513,12 +513,12 @@ test keys_3() {
keys([Pair("a", 0), Pair("b", 0)]) == ["a", "b"]
}

/// Apply a function to all key-value pairs in a map, replacing the values.
/// Apply a function to all key-value pairs in a alist, replacing the values.
///
/// ```aiken
/// let fixture = [Pair("a", 100), Pair("b", 200)]
///
/// map.map(fixture, fn(_k, v) { v * 2 }) == [Pair("a", 200), Pair("b", 400)]
/// alist.map(fixture, fn(_k, v) { v * 2 }) == [Pair("a", 200), Pair("b", 400)]
/// ```
pub fn map(
self: AList<key, value>,
Expand Down Expand Up @@ -549,10 +549,10 @@ test map_2() {
/// Extract all the values present in a given `AList`.
///
/// ```aiken
/// map.values([]) == []
/// map.values([Pair("a", 1)]) == [1]
/// map.values([Pair("a", 1), Pair("b", 2)]) == [1, 2]
/// map.values([Pair("a", 1), Pair("b", 2), Pair("a", 3)]) == [1, 2, 3]
/// alist.values([]) == []
/// alist.values([Pair("a", 1)]) == [1]
/// alist.values([Pair("a", 1), Pair("b", 2)]) == [1, 2]
/// alist.values([Pair("a", 1), Pair("b", 2), Pair("a", 3)]) == [1, 2, 3]
/// ```
pub fn values(self: AList<key, value>) -> List<value> {
when self is {
Expand Down
5 changes: 3 additions & 2 deletions lib/aiken/bytearray.ak
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,9 @@ test from_string_2() {
}

/// Add a byte element in front of a `ByteArray`. When the given byte is
/// greater than 255, it wraps-around. So 256 is mapped to 0, 257 to 1, and so
/// forth.
/// greater than 255, it wraps-around. **PlutusV2 behavior** So 256 is mapped to 0, 257 to 1, and so
/// forth.
/// In PlutusV3 this will error instead of wrapping around.
///
/// ```aiken
/// bytearray.push(#"", 0) == #"00"
Expand Down
Loading