Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,26 @@
|
|||
fn deduplicated<T>(anon array: [T]) throws -> [T] {
|
||||
mut existing_items: {T} = {}
|
||||
mut result: [T] = []
|
||||
for value in array {
|
||||
if not existing_items.contains(value) {
|
||||
existing_items.add(value)
|
||||
result.push(value)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
fn deduplicated_set<T>(anon array: [T]) throws -> {T} {
|
||||
mut result: {T} = {}
|
||||
for value in array {
|
||||
result.add(value)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
fn main() {
|
||||
let array = [1, 2, 3, 3, 2, 5, 4]
|
||||
println("{}", deduplicated(array))
|
||||
println("{}", deduplicated_set(array))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue