Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
26
Task/Nth/DuckDB/nth.duckdb
Normal file
26
Task/Nth/DuckDB/nth.duckdb
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# ordinalize an integer, whether positive or negative
|
||||
create or replace function ordinalize(x) as (
|
||||
x::VARCHAR
|
||||
|| ''''
|
||||
|| if( 11 <= (abs(x) % 100) and (abs(x) % 100) <= 13, 'th',
|
||||
case abs(x) % 10
|
||||
when 1 then 'st'
|
||||
when 2 then 'nd'
|
||||
when 3 then 'rd'
|
||||
else 'th'
|
||||
end)
|
||||
);
|
||||
|
||||
create or replace function task(lst) as (
|
||||
select list_transform(lst, ix -> ordinalize(ix))
|
||||
.array_to_string(' ')
|
||||
);
|
||||
|
||||
## Examples
|
||||
.header off
|
||||
.maxwidth 300
|
||||
.mode list
|
||||
select task(range(-5, -1));
|
||||
select task(range(0,26));
|
||||
select task(range(250,266));
|
||||
select task(range(1000,1026));
|
||||
Loading…
Add table
Add a link
Reference in a new issue