Price fraction: Difference between revisions
Content added Content deleted
m (→{{header|J}}: remove redundant info from Note) |
(simplify J implementation) |
||
Line 132: | Line 132: | ||
=={{header|J}}== |
=={{header|J}}== |
||
'''Solution:''' |
'''Solution:''' |
||
<lang j>ge=: 0 0.06 0.11 0.16 0.21 0.26 0.31 0.36 0.41 0.46 0.51 0.56 0.61 0.66 0.71 0.76 0.81 0.86 0.91 0.96 |
<lang j>ge=: |.-0 0.06 0.11 0.16 0.21 0.26 0.31 0.36 0.41 0.46 0.51 0.56 0.61 0.66 0.71 0.76 0.81 0.86 0.91 0.96 |
||
out=: 0.1 0.18 0.26 0.32 0.38 0.44 0.5 0.54 0.58 0.62 0.66 0.7 0.74 0.78 0.82 0.86 0.9 0.94 0.98 1 |
out=: |.0.1 0.18 0.26 0.32 0.38 0.44 0.5 0.54 0.58 0.62 0.66 0.7 0.74 0.78 0.82 0.86 0.9 0.94 0.98 1 |
||
priceFraction=: out {~ ge I. -</lang> |
|||
priceFraction=: out {~ ge <:@IdotR ]</lang> |
|||
'''Usage:''' |
'''Usage:''' |
||
<lang j> priceFraction 0.34 0.070145 0.06 0.05 0.50214 0.56 1 0.99 0 |
<lang j> priceFraction 0.34 0.070145 0.06 0.05 0.50214 0.56 1 0.99 0 |
||
0.5 0.18 0.18 0.1 0.62 0.7 1 1 0.1</lang> |
0.5 0.18 0.18 0.1 0.62 0.7 1 1 0.1</lang> |
||
'''Note:'''<br> |
|||
If the specification used intervals open to the left rather than open to the right, |
|||
then the verb would simplify to: |
|||
<lang j>le=: }. ge , 1.01 |
|||
priceFraction=: out {~ le I. ]</lang> |
|||
=={{header|Oz}}== |
=={{header|Oz}}== |