Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
24
Task/Nth/Gleam/nth.gleam
Normal file
24
Task/Nth/Gleam/nth.gleam
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import gleam/int
|
||||
import gleam/io
|
||||
|
||||
pub fn main() {
|
||||
show_nths(from: 0, to: 25)
|
||||
show_nths(from: 250, to: 265)
|
||||
show_nths(from: 1000, to: 1025)
|
||||
}
|
||||
|
||||
pub fn nth(n: Int) -> String {
|
||||
int.to_string(n)
|
||||
<> case n % 100, n % 10 {
|
||||
11, _ | 12, _ | 13, _ -> "th"
|
||||
_, 1 -> "st"
|
||||
_, 2 -> "nd"
|
||||
_, 3 -> "rd"
|
||||
_, _ -> "th"
|
||||
}
|
||||
}
|
||||
|
||||
fn show_nths(from x: Int, to y: Int) -> Nil {
|
||||
int.range(x, y, Nil, fn(_, x) { io.print(nth(x) <> " ") })
|
||||
io.println("")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue