TṀị
“¢<<ð¢‘×\×€0¦7,31,365F⁸:µç“ɲþḣ⁹ḢṡṾDU¤µQƝṁ⁼ẹ»Ḳ¤ṭÇK;⁸Ç>1¤¡”s
完整程序打印结果。
(作为单子链接,它返回一个整数列表,后跟字符)
在线尝试!
怎么样?
TṀị - Link 1: list of integers, K; list, V e.g. [86401,1440,24,1,0,0,0], ["second","minute","hour","day","week","month","year"]
T - truthy indexes of K [1,2,3,4]
Ṁ - maximum 4
ị - index into V "day"
“¢<<ð¢‘×\×€0¦7,31,365F⁸:µç“...»Ḳ¤ṭÇK;⁸Ç>1¤¡”s - Main link: integer, N e.g. 3599
“¢<<𢑠- list of code-page indices = [1,60,60,24,1]
\ - cumulative reduce with:
× - multiplication = [1,60,3600,86400,86400]
7,31,365 - list of integers = [7,31,365]
¦ - sparse application...
0 - ...to index: 0 (rightmost)
×€ - ...of: multiplication for €ach = [1,60,3600,86400,[604800,2678400,31536000]]
F - flatten = [1,60,3600,86400,604800,2678400,31536000]
⁸ - chain's left argument, N 3599
: - integer divide [3599,59,0,0,0,0,0]
µ - start a new monadic chain, call that X
¤ - nilad followed by links as a nilad:
“...» - compression of "second minute hour day week month year"
Ḳ - split at spaces = ["second","minute","hour","day","week","month","year"]
ç - call the last link (1) as a dyad - i.e. f(X,["second","minute","hour","day","week","month","year"])
- "minute"
Ç - call the last link (1) as a monad - i.e. f(X,X)
- 59
ṭ - tack [59,['m','i','n','u','t','e']]
K - join with spaces [59,' ','m','i','n','u','t','e']
”s - literal character '
¡ - repeat...
¤ - ...number of times: nilad followed by link(s) as a nilad:
⁸ - chain's left argument, X [3599,59,0,0,0,0,0]
Ç - call the last link (1) as a monad - i.e. f(X,X)
- 59
>1 - greater than 1? 1
; - concatenate [59,' ','m','i','n','u','t','e','s']
- implicit print - smashes to print "59 minutes"