Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
16
Task/Pascals-triangle/DuckDB/pascals-triangle.duckdb
Normal file
16
Task/Pascals-triangle/DuckDB/pascals-triangle.duckdb
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
create or replace function pascal_triangle(n) as table (
|
||||
with recursive cte as (
|
||||
SELECT 0 as i, [1]::BIGINT[] as row,
|
||||
UNION ALL
|
||||
SELECT i+1 as i,
|
||||
([1] || list_transform(row, (x,ix) -> x + (coalesce(row[ix+1], 0)))) as row
|
||||
FROM cte
|
||||
WHERE i < n
|
||||
)
|
||||
select row as "pascal_triangle" FROM cte
|
||||
order by i
|
||||
);
|
||||
|
||||
.print The results for all n<=0 are the same:
|
||||
select * as "pascal_triangle(0)" from pascal_triangle(0);
|
||||
from pascal_triangle(4) _("pascal_triangle(4)");
|
||||
Loading…
Add table
Add a link
Reference in a new issue