Diff type

Represents difference

Direct children types

ArrDiff
Represents difference of elements between two arrays (order unimportant)
HashDiff
Represents difference of elements between two hashes (order unimportant)

Constructors

Diff(a:Arr, b:Arr, full:Bool=false) Source: stdlib.ngs:3162
Compare arrays. Warning: by default Hash is used so internal Hash keys comparison is used, not ==

Parameters

fullDo not use Hash, work slower but use == comparison.

Example

Diff([1,2], [2,3])  # .add = [3] .remove = [1]
Diff(a:Arr, b:Arr, eq:Fun)experimental Source: stdlib.ngs:3182
EXPERIMENTAL! Do not use! Compare arrays using eq as equality test. 2*n*m comparisons

Returns

ArrDiff
Diff(a:Arr, b:Arr, full:Bool=false) Source: stdlib.ngs:3198
Compare arrays. Warning: by default Hash is used so internal Hash keys comparison is used, not ==

Parameters

bArr[PartialPresence]
fullDo not use Hash, work slower but use == comparison.

Returns

ArrDiff

Example

Diff([1,2,3], [Present(1)])  # <ArrDiff add=[] remove=[]>
Diff([1,2,3], [Present(5)])  # <ArrDiff add=[5] remove=[]>
Diff([1,2,3], [Absent(1)])   # <ArrDiff add=[] remove=[1]>
Diff([1,2,3], [Absent(5)])   # <ArrDiff add=[] remove=[]>
Diff(["a", "b"], [Present("a"), Present("c"), Absent("b"), Absent("d")])  # <ArrDiff add=[c] remove=[b]>
Diff(a:Arr, b:Arr, full:Bool=false) Source: stdlib.ngs:3221
Compare arrays. Warning: by default Hash is used so internal Hash keys comparison is used, not ==. Calls Diff(a, b.map(get), full)

Parameters

bArr[ExactPresence]
fullDo not use Hash, work slower but use == comparison.

Returns

Diff
Diff(a:Hash, b:Hash) Source: stdlib.ngs:3249
Compare hashes

Example

diff = Diff(current_tags, target_tags)
if (tags = AWS::cli_tags(diff.add + diff.change)) {
	r.run('update_tags/add', %(aws ec2 create-tags --resources ${r.id()} --tags $*tags))
}
if (tags = diff.remove / "Key=$X") {
	r.run('update_tags/remove', %(aws ec2 delete-tags --resources ${r.id()} --tags $*tags))
}