⁾_@
⁾C×
”+
⁾‘×
ḲµṪḢO%7µĿṭ
ḢW;Ç€j”µFV>0¬
列出具有十进制格式数字的字符串列表
(前导零可以工作,但有副作用,在最终结果之前将零打印到STDOUT)。
在线尝试!-不免费;还是免费的。
怎么样?
⁾_@ - Link 1: a coupon
⁾_@ - literal "_@" - the Jelly code for subtraction with reversed arguments
⁾C× - Link 2: a discount
⁾C× - literal "C×" - the Jelly code for complement (1-input) then multiply
”+ - Link 3: extra cost
”+ - literal '+' - the Jelly code for add
⁾‘× - Link 4: a tip
⁾‘× - literal "‘×" - the Jelly code for increment (input+1) then multiply
ḲµṪḢO%7µĿṭ - Link 5, switch: char list
Ḳ - split on spaces (gives [amount, type] as char lists)
µ µ - monadic chain separation to get a value, say v
Ṫ - tail (get the type: "coupon", "discount", "extra", or "tip")
Ḣ - head (get the first character: 'c', 'd', 'e' or 't')
O - cast to ordinal (99, 100, 101, or 116)
%7 - mod 7 (1, 2, 3, or 4)
Ŀ - call link v as a monad
ṭ - tack to the amount char list
ḢW;Ç€j”µFV>0¬ - Main link: list of strings (char lists)
Ḣ - head - the base price char list
W - wrap in a list
Ç€ - call the last link (5) as a monad for €ach of the rest
; - concatenate
”µ - literal 'µ' - Jelly's monadic chain separator
j - join all the parts with 'µ's "10",".2 tip",".2 discount", "2 coupon","2 coupon","1 coupon",".5 discount","2.55 coupon":
F - flatten (makes a char list, for example: "10µ.20‘×µ.20C×µ2_@µ2_@µ1_@µ.50C×µ2.55_@")
V - evaluate as Jelly code (the above evaluates to -0.2499999999999991)
>0 - greater than 0?
¬ - not