雨滴是 FizzBuzz 挑战的稍微复杂一点的版本,这是一个经典的面试题。
你的任务是把一个数字转换成它对应的雨滴声。
如果给定的数字:
"Plong"。"PlingPlang"。"34"。jq技巧在这个练习里,if-then-else表达式会很有帮助。
例如:
8, 10, 12 | if . < 10 then "\(.) is less than ten"
elif . > 10 then "\(.) is more than ten"
else "\(.) equals ten"
end
输出
"8 is less than ten"
"10 equals ten"
"12 is more than ten"