Price fraction: Difference between revisions

Add J
(→‎{{header|Python}}: extend comment.)
(Add J)
Line 129:
END IF
RETURN nResult</lang>
 
=={{header|J}}==
'''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
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
IdotR=: #@[ - |.@[ I. ]
priceFraction=: out {~ ge <:@IdotR ]</lang>
 
'''Usage:'''
<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>
'''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=: 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 1.01
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 {~ le I. ]</lang>
 
 
=={{header|Oz}}==
Line 148 ⟶ 166:
end
end</lang>
 
=={{header|PureBasic}}==
<lang PureBasic>Procedure.f PriceFraction(price.f)
892

edits