update
This commit is contained in:
parent
1f1ad49427
commit
6f050a029e
2496 changed files with 37609 additions and 3031 deletions
|
|
@ -0,0 +1,14 @@
|
|||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
int main() {
|
||||
std::vector<int> data = {1, 2, 3, 2, 3, 4};
|
||||
|
||||
std::sort(data.begin(), data.end());
|
||||
data.erase(std::unique(data.begin(), data.end()), data.end());
|
||||
|
||||
for(int& i: data) std::cout << i << " ";
|
||||
std::cout << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
int icmp(const void *a, const void *b)
|
||||
{
|
||||
#define _I(x) *(int*)x
|
||||
#define _I(x) *(const int*)x
|
||||
return _I(a) < _I(b) ? -1 : _I(a) > _I(b);
|
||||
#undef _I
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
List = [1, 2, 3, 2, 2, 4, 5, 5, 4, 6, 6, 5].
|
||||
UniqueList = gb_sets:to_list(gb_sets:from_list(List)).
|
||||
% Alternatively the builtin:
|
||||
Unique_list = lists:usort( List ).
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
-> (remove-duplicates '(2 1 3 2.0 a 4 5 b 4 3 a 7 1 3 x 2))
|
||||
'(2 1 3 2.0 a 4 5 b 7 x)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(define (unique/hash lst)
|
||||
(hash-keys (for/hash ([x (in-list lst)]) (values x #t))))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(define unique/set (compose1 set->list list->set))
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(define (unique seq #:same-test [same? equal?])
|
||||
(for/fold ([res '()])
|
||||
([x seq] #:unless (memf (curry same? x) res))
|
||||
(cons x res)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue