Sparkline in unicode: Difference between revisions

Content added Content deleted
Line 24: Line 24:
Note → this is in a 0-indexed version of APL
Note → this is in a 0-indexed version of APL
'''Solution''':<lang APL> sparkln←{'▁▂▃▄▅▆▇█'[⌈7×⍵÷⌈/⍵]}</lang>
'''Solution''':<lang APL> sparkln←{'▁▂▃▄▅▆▇█'[⌈7×⍵÷⌈/⍵]}</lang>
'''Example''':<lang APL> sparkln 1,2,7 1 5
'''Example''':<lang APL> sparkln 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
▁▂▃▄▅▆▇▇▇▆▅▄▃▂▁
▂▃█▂▆</lang>
sparkln 1.5, 0.5 3.5, 2.5 5.5, 4.5 7.5, 6.5
▂▁▄▃▆▅▇▇
</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.
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.