RosettaCodeData/Task/Set-consolidation/DuckDB/set-consolidation-2.duckdb
2025-08-11 18:05:26 -07:00

17 lines
479 B
Text

create or replace function to_set(lst) as (
list_sort(list_distinct(lst))
);
create or replace function list_update(lst, i, value) as (
lst[1:i-1] || [value] || lst[i+1:]
);
# This will work even if set1 and set2 are just lists
create or replace function set_intersection(set1, set2) as (
list_sort(list_intersect(set1, set2))
);
# This will work even if set1 and set2 are just lists
create or replace function set_union(set1, set2) as (
to_set( ( set1 || set2 ) )
);