Anonymous user
Sparkline in unicode: Difference between revisions
Updated to work with Nim 1.4: changed "True" to "true"; added import of "sequtils" (for "map"). Also, used directly the UTF-8 strings for the chars (no need for module "unicode"), changed precision to -1, added "filterIt"..
m (→{{header|Phix}}: no_empty param is no more) |
(Updated to work with Nim 1.4: changed "True" to "true"; added import of "sequtils" (for "map"). Also, used directly the UTF-8 strings for the chars (no need for module "unicode"), changed precision to -1, added "filterIt"..) |
||
Line 1,654:
=={{header|Nim}}==
{{trans|Python}}
<lang nim>import rdstdin,
const bar = [
const barcount = float(bar.high)
while
let
line = readLineFromStdin "Numbers please separated by space/commas: "
numbers = line.split({' ', ','}).filterIt(it.len != 0).map(parseFloat)
mn = min(numbers)
mx = max(numbers)
Line 1,668:
var sparkline = ""
for n in numbers:
let i = int((n - mn) / extent * barcount)
sparkline.add
echo "min: ", mn.formatFloat(precision = 0), "; max: ", mx.formatFloat(precision =
echo sparkline</lang>
{{out}}
|