2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
28
Task/Nth/Factor/nth.factor
Normal file
28
Task/Nth/Factor/nth.factor
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
USING: math kernel combinators math.ranges math.parser
|
||||
sequences io ;
|
||||
IN: nth
|
||||
|
||||
: tens-digit ( n -- n ) 10 [ /i ] [ mod ] bi ;
|
||||
|
||||
: teens? ( n -- ? ) tens-digit 1 = ;
|
||||
|
||||
: non-teen-suffix ( n -- str )
|
||||
10 mod {
|
||||
{ 1 [ "st" ] }
|
||||
{ 2 [ "nd" ] }
|
||||
{ 3 [ "rd" ] }
|
||||
[ drop "th" ]
|
||||
} case ;
|
||||
|
||||
: ordinal-suffix ( n -- str )
|
||||
dup teens? [ drop 0 ] when non-teen-suffix ;
|
||||
|
||||
: join-suffix ( n -- str ) dup ordinal-suffix
|
||||
[ number>string ] dip append ;
|
||||
|
||||
: main ( -- )
|
||||
0 25 250 265 1000 1025 [ [a,b] ] 2tri@
|
||||
[ [ join-suffix ] map ] tri@
|
||||
[ [ bl ] [ write ] interleave nl ] tri@ ;
|
||||
|
||||
MAIN: main
|
||||
Loading…
Add table
Add a link
Reference in a new issue