Sparkline in unicode: Difference between revisions

m
syntax highlighting fixup automation
m (syntax highlighting fixup automation)
Line 36:
=={{header|APL}}==
Note → this is in a 0-indexed version of APL
'''Solution''':<langsyntaxhighlight APLlang="apl"> sparkln←{'▁▂▃▄▅▆▇█'[⌊0.5+7×⍵÷⌈/⍵]}</langsyntaxhighlight>
'''Example''':<langsyntaxhighlight APLlang="apl"> sparkln 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
▂▃▄▅▅▆▇█▇▆▅▅▄▃▂
sparkln 1.5, 0.5 3.5, 2.5 5.5, 4.5 7.5, 6.5
▂▁▄▃▆▅█▇
</syntaxhighlight>
</lang>
Note → APL accepts the input with commas and spaces naturally. If one wanted to read input as a string they could use ⍎⍞ to do so.
 
=={{header|AppleScript}}==
<langsyntaxhighlight AppleScriptlang="applescript">use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
Line 360:
set my text item delimiters to dlm
return s
end unwords</langsyntaxhighlight>
{{Out}}
<pre>▁▁██
Line 392:
=={{header|Arturo}}==
 
<langsyntaxhighlight lang="rebol">bar: "▁▂▃▄▅▆▇█"
barcount: to :floating dec size bar
 
Line 409:
print sparkLine
print ""
]</langsyntaxhighlight>
 
{{out}}
Line 424:
=={{header|AutoHotkey}}==
{{works with|AutoHotkey_L}}
<langsyntaxhighlight AutoHotkeylang="autohotkey">SetFormat, FloatFast, 0.1
strings := ["1 2 3 4 5 6 7 8 7 6 5 4 3 2 1"
, "1.5, 0.5 3.5, 2.5 5.5, 4.5 7.5, 6.5"]
Line 446:
Chars .= Chr(0x2581 + Round(7 * (A_LoopField - Min) / Rng))
return, {"Min": Min, "Max": Max, "Rng": Rng, "Chars": Chars}
}</langsyntaxhighlight>
{{out}}
<pre>Min: 1, Max: 8, Range: 7
Line 458:
===Linux version===
Accepts data via command line, prints out usage on incorrect invocation.
<syntaxhighlight lang="c">
<lang C>
#include<string.h>
#include<stdlib.h>
Line 506:
return 0;
}
</syntaxhighlight>
</lang>
Invocation and output :
<pre>
Line 519:
=={{header|C++}}==
 
<langsyntaxhighlight lang="cpp">
#include <iostream>
#include <sstream>
Line 587:
 
return 0;
}</langsyntaxhighlight>
{{out}}
<pre>Min: 1; Max: 8; Range: 7
Line 595:
 
=={{header|Clojure}}==
<langsyntaxhighlight Clojurelang="clojure">(defn sparkline [nums]
(let [sparks "▁▂▃▄▅▆▇█"
high (apply max nums)
Line 609:
(recur (read-line)))))
 
(spark (read-line))</langsyntaxhighlight>
 
{{Out}}
Line 618:
 
=={{header|Common Lisp}}==
<langsyntaxhighlight lang="lisp">(defun buckets (numbers)
(loop with min = (apply #'min numbers)
with max = (apply #'max numbers)
Line 660:
 
(string->sparkline "1 2 3 4 5 6 7 8 7 6 5 4 3 2 1")
(string->sparkline "1.5, 0.5 3.5, 2.5 5.5, 4.5 7.5, 6.5")</langsyntaxhighlight>
{{out}}
<pre>Min: 1, Max: 8, Range: 7
Line 669:
=={{header|D}}==
{{trans|Python}}
<langsyntaxhighlight lang="d">void main() {
import std.stdio, std.range, std.algorithm, std.conv,
std.string, std.regex;
Line 684:
immutable div = (mm[1] - mm[0]) / (bars.length - 1);
numbers.map!(n => bars[cast(int)((n - mm[0]) / div)]).writeln;
}</langsyntaxhighlight>
The output is the same as the Python entry
(but it only accepts one series of values at a time).
=={{header|Delphi}}==
<syntaxhighlight lang="delphi">
<lang Delphi>
program Sparkline_in_unicode;
 
Line 739:
Readln;
end.
</syntaxhighlight>
</lang>
=={{header|Elixir}}==
<langsyntaxhighlight lang="elixir">defmodule RC do
def sparkline(str) do
values = str |> String.split(~r/(,| )+/)
Line 748:
IO.puts Enum.map(values, &(round((&1 - min) / (max - min) * 7 + 0x2581)))
end
end</langsyntaxhighlight>
Usage:
<syntaxhighlight lang="text">str1 = "1 2 3 4 5 6 7 8 7 6 5 4 3 2 1"
str2 = "1.5, 0.5 3.5, 2.5 5.5, 4.5 7.5, 6.5"
 
RC.sparkline(str1)
IO.puts "" # newline
RC.sparkline(str2)</langsyntaxhighlight>
{{out}}
<pre>
Line 764:
 
=={{header|F_Sharp|F#}}==
<langsyntaxhighlight lang="fsharp">open System
open System.Globalization
open System.Text.RegularExpressions
Line 785:
|> List.map (fun x -> bars.[int ((x - min)/(max - min) * barsCount)])
|> String.Concat
|> printfn "%s"</langsyntaxhighlight>
{{out}}
<pre>Numbers separated by anything: 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
Line 797:
 
=={{header|Factor}}==
<langsyntaxhighlight lang="factor">USING: formatting kernel math math.order math.parser
math.statistics sequences splitting ;
 
Line 814:
"0, 1, 19, 20"
"0, 999, 4000, 4999, 7000, 7999"
} [ dup sparkline "%u -> %s\n" printf ] each</langsyntaxhighlight>
{{out}}
<pre>
Line 824:
 
=={{header|FALSE}}==
<langsyntaxhighlight lang="false">{
variables:
s: sign (1 or -1)
Line 891:
q;1-q: {move pointer}
]#
]?</langsyntaxhighlight>
This implementation can only accept one series of numbers at a time.
{{out}}
Line 900:
 
=={{header|Go}}==
<langsyntaxhighlight lang="go">package main
 
import (
Line 973:
}
return
}</langsyntaxhighlight>
{{out}}
<pre>
Line 1,011:
 
=={{header|Groovy}}==
<langsyntaxhighlight lang="groovy">def sparkline(List<Number> list) {
def (min, max) = [list.min(), list.max()]
def div = (max - min) / 7
list.collect { (char)(0x2581 + (it-min) * div) }.join()
}
def sparkline(String text) { sparkline(text.split(/[ ,]+/).collect { it as Double }) }</langsyntaxhighlight>
Test Code
<langsyntaxhighlight lang="groovy">["1 2 3 4 5 6 7 8 7 6 5 4 3 2 1", "1.5, 0.5 3.5, 2.5 5.5, 4.5 7.5, 6.5"].each { dataset ->
println " Dataset: $dataset"
println "Sparkline: ${sparkline(dataset)}"
}</langsyntaxhighlight>
{{out}}
<pre>
Line 1,031:
 
=={{header|Haskell}}==
<langsyntaxhighlight lang="haskell">import Data.List.Split (splitOneOf)
import Data.Char (chr)
 
Line 1,087:
, "3 2 1 0 -1 -2 -3 -4 -3 -2 -1 0 1 2 3"
, "-1000 100 1000 500 200 -400 -700 621 -189 3"
]</langsyntaxhighlight>
{{Out}}
<pre>▁▁██
Line 1,105:
Or, stripping back a little:
{{Trans|Python}}
<langsyntaxhighlight lang="haskell">import Data.Bifunctor (bimap)
import Data.List (findIndex)
import Data.List.Split (splitOneOf)
Line 1,141:
fmap read
. filter (not . null)
. splitOneOf " ,"</langsyntaxhighlight>
{{Out}}
<pre>▁▁██
Line 1,149:
 
=={{header|J}}==
'''Solution''' (''explicit''):<langsyntaxhighlight lang="j"> spkln =: verb define
y spkln~ 4 u:16b2581+i.8 NB. ▁▂▃▄▅▆▇█
:
Line 1,155:
N =. # x
x {~ <. (N-1) * (y-MIN) % MAX-MIN
)</langsyntaxhighlight>
'''Solution''' (''tacit''):<langsyntaxhighlight lang="j"> spkln =: (4 u:16b2581+i.8)&$: : ([ {~ <:@#@[ <.@* ] (- % >./@[ - ]) <./@])</langsyntaxhighlight>
'''Solution''' (''look Ma, no hands!''):<langsyntaxhighlight lang="j"> spkln =: (u:9601+i.8)&$: : ([ {~ ((<.@* <:@#)~ ((- % (- >./))~ <./)))</langsyntaxhighlight>
'''Examples''':<pre> spkln 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
▁▂▃▄▅▆▇█▇▆▅▄▃▂▁
Line 1,167:
 
=={{header|Java}}==
<langsyntaxhighlight lang="java">
public class Sparkline
{
Line 1,209:
}
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,223:
===ES6===
 
<langsyntaxhighlight JavaScriptlang="javascript">(() => {
'use strict';
 
Line 1,380:
// MAIN ---
return main();
})();</langsyntaxhighlight>
{{Out}}
<pre>▁▁██
Line 1,399:
 
=={{header|jq}}==
<langsyntaxhighlight lang="jq">def sparkline:
min as $min
| ( (max - $min) / 7 ) as $div
Line 1,407:
def string2array:
def tidy: select( length > 0 );
[split(" ") | .[] | split(",") | .[] | tidy | tonumber];</langsyntaxhighlight>
'''Task'''
( "1 2 3 4 5 6 7 8 7 6 5 4 3 2 1",
Line 1,418:
 
=={{header|Julia}}==
<langsyntaxhighlight lang="julia">function sparklineit(arr)
sparkchars = '\u2581':'\u2588'
dyn = length(sparkchars)
Line 1,436:
arrays = map(lin -> split(lin, r"\s+|\s*,\s*") .|> s -> parse(Float64, s), lines)
foreach(v -> println("$v → ", sparklineit(v)), arrays)
</syntaxhighlight>
</lang>
{{out}}
<pre>[6, 3, 9, 5, 1, 10, 0, 1, 3, 6] → ▅▃█▄▁█▁▁▃▅
Line 1,445:
=={{header|Kotlin}}==
{{trans|Java}}
<langsyntaxhighlight lang="scala">internal const val bars = "▁▂▃▄▅▆▇█"
internal const val n = bars.length - 1
 
Line 1,466:
println(s2)
println(s2.toSparkline())
}</langsyntaxhighlight>
{{Out}}
<pre>1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
Line 1,474:
 
=={{header|LiveCode}}==
<langsyntaxhighlight LiveCodelang="livecode">command sparklines listOfNums
local utfbase=0x2581
local tStats, utfp, tmin,tmax,trange
Line 1,495:
end repeat
put plot
end sparklines</langsyntaxhighlight>
 
Test
Line 1,514:
 
 
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module CheckIt {
Function Row$(a) {
Line 1,549:
}
Checkit
</syntaxhighlight>
</lang>
 
Function Param() get a string an put it as inline code in expressions
 
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module CheckIt {
Font "Dejavu Sans Mono"
Line 1,581:
}
Checkit
</syntaxhighlight>
</lang>
 
Third program use strings for stack input, which skip coma as white space. We have to pass to current stack, here calling a function (which always have a new stack for values). First we flush the stack (make it empty), then we use Stack Dat$ to parse the dat$ (also empty the string). Last we rtuern an array using array() using as argument a stack object. Read only function [] do two things replace the current stack object with an empty one, and return the old stack.
 
 
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module CheckIt {
Function ExtractDat(dat$) {
Line 1,619:
}
Checkit
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,629:
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">toSparkline[data_String] := FromCharacterCode[Round[7 Rescale@Flatten@ImportString[data, "Table", "FieldSeparators" -> {" ", ","}]] + 16^^2581];</langsyntaxhighlight>
<pre>
toSparkline["1 2 3 4 5 6 7 8 7 6 5,4 3 2 1 "]
Line 1,639:
 
=={{header|NetRexx}}==
<langsyntaxhighlight NetRexxlang="netrexx">/* NetRexx */
options replace format comments java crossref symbols nobinary
 
Line 1,693:
return
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,705:
=={{header|Nim}}==
{{trans|Python}}
<langsyntaxhighlight lang="nim">import rdstdin, sequtils, strutils
 
const bar = ["\u2581", "\u2582", "\u2583", "\u2584", "\u2585", "\u2586", "\u2587", "\u2588"]
Line 1,722:
sparkline.add bar[i]
echo "min: ", mn.formatFloat(precision = 0), "; max: ", mx.formatFloat(precision = -1)
echo sparkline</langsyntaxhighlight>
{{out}}
<pre>Numbers please separated by space/commas: 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
Line 1,732:
 
=={{header|OCaml}}==
<langsyntaxhighlight lang="ocaml">let before_first_bar = 0x2580
let num_bars = 8
 
Line 1,770:
|> String.split_on_char ';'
|> List.iter print_sparkline
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,788:
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">binmode(STDOUT, ":utf8");
our @sparks=map {chr} 0x2581 .. 0x2588;
sub sparkline(@) {
Line 1,817:
# one sparkline per line
print sparkline( split /[\s,]+/ ) while <>;
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,860:
=={{header|Phix}}==
Works fine on Linux, with or without unicode_console.e as that does little apart from check environment settings for clues, but on my Windows box, on which it invokes kernel32/SetConsoleOutputCP(CP_UTF8), unicode_console.e improves it only slightly, getting just two of the eight characters right. Changing the font on the windows(10) console to "NSimSum" or "SimSun-ExtB" (manually, by right clicking on the title bar and selecting properties/fonts) improves things considerably - suggestions welcome.
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #7060A8;">requires</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"1.0.2"</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- (a fix for JS)</span>
Line 1,889:
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 1,907:
 
=={{header|PicoLisp}}==
<langsyntaxhighlight PicoLisplang="picolisp">(de sparkLine (Lst)
(let (Min (apply min Lst) Max (apply max Lst) Rng (- Max Min))
(for N Lst
(prin
(char (+ 9601 (*/ (- N Min) 7 Rng)) ) ) )
(prinl) ) )</langsyntaxhighlight>
Test:
<langsyntaxhighlight PicoLisplang="picolisp">(sparkLine (str "1 2 3 4 5 6 7 8 7 6 5 4 3 2 1"))
(sparkLine (scl 1 (str "1.5, 0.5 3.5, 2.5 5.5, 4.5 7.5, 6.5")))</langsyntaxhighlight>
Output:
<pre>▁▂▃▄▅▆▇█▇▆▅▄▃▂▁
Line 1,921:
 
=={{header|Python}}==
<langsyntaxhighlight lang="python"># -*- coding: utf-8 -*-
 
# Unicode: 9601, 9602, 9603, 9604, 9605, 9606, 9607, 9608
Line 1,945:
mn, mx, sp = sparkline(numbers)
print(' min: %5f; max: %5f' % (mn, mx))
print(" " + sp)</langsyntaxhighlight>
 
{{out}}
Line 1,979:
If the search result is 'not found' (Nothing), then we use the highest (nominally 8th, or index 7) block.
 
<langsyntaxhighlight lang="python">'''Sparkline in Unicode'''
 
from functools import reduce
Line 2,148:
# MAIN ---
if __name__ == '__main__':
main()</langsyntaxhighlight>
{{Out}}
<pre>▁▁██
Line 2,167:
 
=={{header|R}}==
<langsyntaxhighlight lang="rsplus">
bars <- intToUtf8(seq(0x2581, 0x2588), multiple = T) # ▁ ▂ ▃ ▄ ▅ ▆ ▇ █
n_chars <- length(bars)
Line 2,191:
sparkline(c(0, 0, 1, 1))
sparkline(c(0, 1, 19, 20))
</syntaxhighlight>
</lang>
{{out}}
<syntaxhighlight lang="r">
<lang r>
[1] "▂▁▄▃▆▅█▇"
[1] "▁▂▃▄▅▆▇█▇▆▅▄▃▂▁"
Line 2,200:
[1] "▁▁██"
[1] "▁▁██"
</syntaxhighlight>
</lang>
 
=={{header|Racket}}==
<langsyntaxhighlight lang="racket">
#lang racket (require syntax/parse)
 
Line 2,217:
(sparks "1 2 3 4 5 6 7 8 7 6 5 4 3 2 1")
(sparks "1.5, 0.5 3.5, 2.5 5.5, 4.5 7.5, 6.5")
</syntaxhighlight>
</lang>
{{out}}
<langsyntaxhighlight lang="racket">
"▁▂▃▄▅▆▇█▇▆▅▄▃▂▁"
"▂▁▄▃▆▅█▇"
</syntaxhighlight>
</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
<syntaxhighlight lang="raku" perl6line>constant @bars = '▁' ... '█';
while prompt 'Numbers separated by anything: ' -> $_ {
my @numbers = map +*, .comb(/ '-'? [[\d+ ['.' \d*]?] | ['.' \d+]] /);
Line 2,232:
say "min: $mn.fmt('%5f'); max: $mx.fmt('%5f')";
say @bars[ @numbers.map: { @bars * ($_ - $mn) / ($mx - $mn) min @bars - 1 } ].join;
}</langsyntaxhighlight>
{{out}}
<pre>Numbers separated by anything: 9 18 27 36 45 54 63 72 63 54 45 36 27 18 9
Line 2,252:
{{Works with|ooRexx}}
{{Works with|Regina|3.4}}
<langsyntaxhighlight REXXlang="rexx">/* Rexx */
 
parse arg aaa
Line 2,319:
return
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 2,344:
 
It should also be noted that the CMS and TSO versions of REXX (and practically all others) don't support ''single line comments''.
<langsyntaxhighlight lang="rexx">/*REXX program displays a sparkline (spark graph) for a group of values. */
if arg()==0 then do /*Optional arguments? Then use defaults*/
call sparkGraph 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
Line 2,368:
end /*j*/
 
say 'output: ' z; say; return /*show the output, + a blank line*/</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
Line 2,380:
=={{header|Ruby}}==
{{trans|Raku}} with added protection for input like "0 0 0 0".
<langsyntaxhighlight lang="ruby">bar = ('▁'..'█').to_a
loop {print 'Numbers please separated by space/commas: '
numbers = gets.split(/[\s,]+/).map(&:to_f)
Line 2,387:
div = (max - min) / (bar.size - 1)
puts min == max ? bar.last*numbers.size : numbers.map{|num| bar[((num - min) / div).to_i]}.join
}</langsyntaxhighlight>
 
{{out}} Used Go testcases
Line 2,414:
 
=={{header|Rust}}==
<langsyntaxhighlight lang="rust">
const BARS: &'static str = "▁▂▃▄▅▆▇█";
 
Line 2,432:
print_sparkline(s2);
}
</syntaxhighlight>
</lang>
{{out}}
"▁▂▃▄▅▆▇█▇▆▅▄▃▂▁"
Line 2,439:
 
=={{header|S-lang}}==
<langsyntaxhighlight Slang="s-lang">
% Just to demonstrate alternate ways of defining unicode:
private variable spchrs = "\u{2581}\u{2582}\u{2583}\u{2584}\u{2585}\u{2586}\u{2587}\u{2588}";
Line 2,465:
sparkline("1 2 3 4 5 6 7 8 7 6 5 4 3 2 1");
sparkline("1.5, 0.5 3.5, 2.5 5.5, 4.5 7.5, 6.5 ");
</syntaxhighlight>
</lang>
{{out}}
"▁▂▃▄▅▆▇█▇▆▅▄▃▂▁"
Line 2,472:
 
=={{header|Scala}}==
<langsyntaxhighlight lang="scala">def mkSparks( numStr:String ) : String =
numStr.split( "[\\s,]+" ).map(_.toFloat) match {
case v if v.isEmpty => ""
Line 2,487:
 
// A random test...
println( mkSparks( Stream.continually( math.abs(util.Random.nextInt % 8)).take(64).mkString(" ") ))</langsyntaxhighlight>
{{out}}
<pre> ▁▂▃▄▅▆▇█▇▆▅▄▃▂▁
Line 2,494:
 
=={{header|Seed7}}==
<langsyntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "scanfile.s7i";
include "float.s7i";
Line 2,546:
data := readDataLine;
end while;
end func;</langsyntaxhighlight>
 
{{out}}
Line 2,559:
=={{header|SenseTalk}}==
This solution makes use of SenseTalk's "word" chunks, in this case delimited by any number of spaces and/or commas, to simplify parsing the input string. Also note the use of the <code>but no more than</code> operator to handle the edge case where a number equal to the top value would otherwise refer to the 9th symbol, which doesn't exist.
<langsyntaxhighlight lang="sensetalk">put sparklineGraph of "1 2 3 4 5 6 7 8 7 6 5 4 3 2 1"
put sparklineGraph of "1.5, 0.5 3.5, 2.5 5.5, 4.5 7.5, 6.5"
put sparklineGraph of "0, 1, 19, 20"
Line 2,578:
return graph
end sparklineGraph
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 2,589:
=={{header|Sidef}}==
{{trans|Ruby}}
<langsyntaxhighlight lang="ruby">var bar = @('▁'..'█');
loop {
print 'Numbers, please, separated by space/commas: ';
Line 2,597:
var div = ((max - min) / bar.end);
say (min == max ? bar.last*numbers.len : numbers.map{|num| bar[(num - min) / div]}.join);
}</langsyntaxhighlight>
{{out}}
<pre>Numbers, please, separated by space/commas: 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
Line 2,608:
=={{header|Tcl}}==
{{works with|Tcl|8.6}}
<langsyntaxhighlight lang="tcl">package require Tcl 8.6
 
proc extractValues {series} {
Line 2,622:
set max [tcl::mathfunc::max {*}$values]
return [join [lmap v $values {renderValue $min $max $v}] ""]
}</langsyntaxhighlight>
Demonstrating:
<langsyntaxhighlight lang="tcl">set data {
"1 2 3 4 5 6 7 8 7 6 5 4 3 2 1"
"1.5, 0.5 3.5, 2.5 5.5, 4.5 7.5, 6.5"
Line 2,631:
puts "Series: $series"
puts "Sparkline: [sparkline $series]"
}</langsyntaxhighlight>
{{out}}
<pre>
Line 2,641:
 
=={{header|VBScript}}==
<syntaxhighlight lang="vb">
<lang vb>
'Sparkline
 
Line 2,713:
 
wscript.stdout.write "Press any key.." : wscript.stdin.read 1
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 2,744:
{{trans|Go}}
{{libheader|Wren-pattern}}
<langsyntaxhighlight lang="ecmascript">import "io" for Stdin, Stdout
import "/pattern" for Pattern
 
Line 2,799:
System.print(s)
System.print()
}</langsyntaxhighlight>
 
{{out}}
Line 2,837:
 
=={{header|zkl}}==
<langsyntaxhighlight lang="zkl">var sparks=[0x2581..0x2588].apply("toString",-8); // int.toString(-8)-->UTF-8
var sl=(sparks.len()-1);
Line 2,845:
println("Range [",min,"-",max,"]", xs);
xs.pump(String,'wrap(x){ sparks[(x - min)*sl/range] }).println();
}</langsyntaxhighlight>
<langsyntaxhighlight lang="zkl">one:="1 2 3 4 5 6 7 8 7 6 5 4 3 2 1".split(" ").apply("toInt");
two:=("1.5, 0.5 3.5, 2.5 5.5 4.5 7.5, 6.5" - ",").split(" ").apply("toFloat");
sparkLine(one); sparkLine(two);</langsyntaxhighlight>
{{out}}
<pre>
Line 2,858:
 
=={{header|Zoea}}==
<syntaxhighlight lang="zoea">
<lang Zoea>
program: sparkline
input: '1 2, 3 4.5 5 6,7 8'
Line 2,864:
derive: [1,2,3,4,5,6,7,8]
output: '▁▂▃▄▅▆▇█'
</syntaxhighlight>
</lang>
 
=={{header|Zoea Visual}}==
10,333

edits