Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
16
Task/Nth/Prolog/nth.pro
Normal file
16
Task/Nth/Prolog/nth.pro
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
nth(N, N_Th) :-
|
||||
( tween(N) -> Th = "th"
|
||||
; 1 is N mod 10 -> Th = "st"
|
||||
; 2 is N mod 10 -> Th = "nd"
|
||||
; 3 is N mod 10 -> Th = "rd"
|
||||
; Th = "th" ),
|
||||
string_concat(N, Th, N_Th).
|
||||
|
||||
tween(N) :- Tween is N mod 100, between(11, 13, Tween).
|
||||
|
||||
test :-
|
||||
forall( between(0,25, N), (nth(N, N_Th), format('~w, ', N_Th)) ),
|
||||
nl, nl,
|
||||
forall( between(250,265,N), (nth(N, N_Th), format('~w, ', N_Th)) ),
|
||||
nl, nl,
|
||||
forall( between(1000,1025,N), (nth(N, N_Th), format('~w, ', N_Th)) ).
|
||||
Loading…
Add table
Add a link
Reference in a new issue