Last active
April 19, 2020 06:10
-
-
Save apstndb/32e20316081cefd1568fe9ca016be082 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "list" | |
a: [{id: 1}, {id: 2}] | |
b: [{id: 1}, {id: 1}] | |
c: [{id: 1}, {id: 2}, {id: 2}] | |
a_ids:: [x.id for x in a] | |
a_unique: list.UniqueItems(a_ids) | |
unique :: { | |
input : _ | |
output : list.UniqueItems([x.id for x in input]) | |
} | |
b_unique : (unique & {input: b}).output | |
c_unique : (unique & {input: c}).output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "list" | |
a: [{id: 1}, {id: 2}] | |
b: [{id: 1}, {id: 2}, {id: 2}] | |
func1:: {input: _, output: _} | |
unique_by:: { | |
f: func1 | |
input: _ | |
output: list.UniqueItems([(f & {input: x}).output for x in input]) | |
} | |
get_id:: func1 & { | |
input: _ | |
output: input.id | |
} | |
a_unique : (unique_by & {input: a, f: get_id}).output | |
b_unique : (unique_by & {input: b, f: get_id}).output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment