Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
68
Task/Sparkline-in-unicode/FALSE/sparkline-in-unicode.false
Normal file
68
Task/Sparkline-in-unicode/FALSE/sparkline-in-unicode.false
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
variables:
|
||||
s: sign (1 or -1)
|
||||
u: current number
|
||||
f: current number fraction length
|
||||
v: current number is valid
|
||||
t: number of numbers read
|
||||
x: biggest fraction
|
||||
y: smallest number (without fraction)
|
||||
z: biggest number (without fraction)
|
||||
}
|
||||
|
||||
{function a: test if top is 0-9, without popping the value, codes 48-57 are in range}
|
||||
[$$47>\57>~&]a:
|
||||
|
||||
{function b: test if top is ',' or ' ', without popping the value}
|
||||
[$$',=\' =|]b:
|
||||
|
||||
{function c: read a number from the input, given that the first character of the input is already on the stack}
|
||||
[
|
||||
1s:0u:0f:0v: {reset values}
|
||||
|
||||
$'-=[1_s:%^]? {if (it is negative) set the sign value to -1 move to next}
|
||||
[a;!][48-u;10*+u:1_v:^]# {while (isnumber) do number = number * 10 + decimal and set valid number and move to next}
|
||||
$'.=[ {if (it is a decimal) move forward and read fraction}
|
||||
%^
|
||||
[a;!][48-u;10*+u:f;1+f:1_v:^]# {while (isnumber) do number = number * 10 + decimal and increase fraction length and set valid number and move to next}
|
||||
]?
|
||||
$$'-=\'.=|[0v:]? {if next charachter is a '-' or a '.', set invalid}
|
||||
]c:
|
||||
|
||||
{function d: normalize number/fraction from stack to max fraction and push that number}
|
||||
[
|
||||
[$x;=~][1+\10*\]# {while (fraction != max) fraction + 1, value * 10}
|
||||
% {pop fraction}
|
||||
]d:
|
||||
|
||||
0t:
|
||||
0x:
|
||||
1_v: { nothing read, so we are still valid }
|
||||
^[b;!][%^]# {read away any initial separators}
|
||||
[$1_=~v;&][ {while input != -1 and valid input, leaving input on the stack}
|
||||
c;! {read a number}
|
||||
t;1+t:u;s;*f;@ {increase count, push number * sign and fraction length onto the stack and bring input back up}
|
||||
f;x;>[f;x:]? {set fraction to biggest of current and previous biggest}
|
||||
[b;!][%^]# {while (isseparator) move forward}
|
||||
]#
|
||||
v;~["error at charachter ",]? {if invalid number, tell them when}
|
||||
v;[ {if last number also valid, do the math}
|
||||
% {pop the -1}
|
||||
t;2*1-q: {var q: points to next value}
|
||||
0p: {var p: whether min/max have been set}
|
||||
[q;1+t;>][ {while q + 1 > t}
|
||||
q;ø {current number}
|
||||
q;ø {current fraction}
|
||||
d;! {normalize}
|
||||
p;[$y;\>[$y:]? $z;>[$z:]?]? {compare min/max}
|
||||
p;~[1_p:$y:$z:]? {if (first)) set min/max}
|
||||
q;1-q: {move pointer}
|
||||
]#
|
||||
|
||||
t;q: {point q to first value}
|
||||
[q;0>][ {while q > 0}
|
||||
q;1-øy;-7*z;y;-/ {(number - minvalue) * 7 / (maxvalue - minvalue), should result in 0..7}
|
||||
9601+, {print character}
|
||||
q;1-q: {move pointer}
|
||||
]#
|
||||
]?
|
||||
Loading…
Add table
Add a link
Reference in a new issue