[Question]
  [
This is a simple one: print an ASCII [Gantt chart](https://en.wikipedia.org/wiki/Gantt_chart).
Given tasks' ranges (start-time - end-time Tuples), print a Gantt timeline in the form of `-` characters for each task duration - each task in a new line.
### Example
Say my tasks ranges are `28->35, 34->40, 39->44`, the Gantt will look like this:
```
                            -------
                                  ------
                                       -----
```
### Specifications
* You can write a full program, a named function or an anonymous function.
* Your program/function should accept the tasks via STDIN **or as arguments**.
* Each task should be represented as a string of `start->end` where `start` and `end` are **Integers**. Tasks are separated by spaces or commas. **Alternatively**, you may get it as a Tuple of Integers, or as an Array/Collection of 2 Integers. (For example, in JavaScript you can get it as `[start,end]` - this is allowed).
* Any non-negative number of tasks (arguments) should be supported.
* To make it clear, a single argument of tasks collection is not allowed. You can either parse a single string argument, or support zero-or-more tasks arguments. Where task is a tuple or a collection of size 2.
* You can assume only valid input will be given. That means, each task has a positive duration.
* Return value does not matter, your code must print the timeline on STDOUT.
* Output: per task, `start` spaces followed by `(end-start)` dashes and a `\n`.
* Needless to say, output lines should be ordered correspondingly with the input (tasks) order.
* Trailing spaces before the `\n` are allowed, if that helps you.
### Test cases
```
Input:
(empty)
Output:
(empty)
Input:
0->7,5->6,3->6
Output:
-------
     -
   ---
Input:
5->20,5->20,2->10,15->19
Output:
     ---------------
     ---------------
  --------
               ----
```
### Winning
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so the least code length (in bytes) wins.
* Traditionally, tie breaker is earlier post.
* "Standard loopholes are no longer funny".
## -----
## EDIT
As many of you understood that it is allowed to have a single tasks collection argument, and since there's no much different between that and the original [varargs](https://en.wikipedia.org/wiki/Variadic_function) requirement,
**it is now allowed to have a single collection argument, if you don't want to use the varargs option, or in case your language does not support varargs.**
  
[Answer]
# Python 2, 39 Bytes
Straightforward solution using string multiplication :)
```
for x,y in input():print' '*x+'-'*(y-x)
```
Accepts input formatted like so:
```
((5,20),(5,20),(2,10),(15,19))
```
[Check it out here.](http://ideone.com/hPZ0bv)
[Answer]
# CJam, ~~16~~ 14 bytes
```
q~{S.*~'-e]N}/
```
This expects a list of lists as input. For example:
```
[[5 20] [5 20] [2 10] [5 19]]
```
gives:
```
     ---------------
     ---------------
  --------
     --------------
```
**How it works**
```
q~                      e# Read the input and parse it as a list of list
  {         }/          e# Go over each item in the list in a for loop
   S                    e# S is basically this string - " "
    .*                  e# Multiply each item of the first list with the corresponding index
                        e# item of the second list. This basically repeats the space
                        e# X times where X is the first number of the tuple. The second
                        e# number remains untouched as the second list was only 1 char long
      ~                 e# Unwrap the space string and second number containing list
       '-               e# Put character '-' on stack
         e]             e# Make sure that the space is filled with - to its right so as to
                        e# make the total length of the string equal to the second number
           N            e# Put a newline. After all iterations, the result is printed
                        e# automatically to STDOUT
```
[Try it online here](http://cjam.aditsu.net/#code=q%7E%7BS.*%7E%27-e%5DN%7D%2F&input=%5B%5B5%2020%5D%20%5B5%2020%5D%20%5B2%2010%5D%20%5B5%2019%5D%5D)
[Answer]
## Brainfuck, ~~120~~ ~~115~~ 111 bytes
At least it's shorter than Java :) The input is a list of bytes, where each pair is a single line in the gantt.
```
++++[->++++++++<]>[->+>+<<]++++++++++>>+++++++++++++>+[,[->+>+<<]>>[-<<+>>],<[->-<<<<.>>>]>[-<<<.>>>]<<<<<.>>>]
```
**Try out**
<http://copy.sh/brainfuck/>
Set end-of-input to `char` with value `\0`. Example input: `\5\20\5\20\2\10\15\19`.
*Note that setting the end-of-input value to `\0` will have the side effect that no more input will be read (and thus stopping the program) when the input contains the number zero. In BF there is no other way of knowing when the input is exhausted.*
**Explanation\***
```
++++[->++++++++<]>  #Store <space> at index 1                   
[->+>+<<]           #Move index 1 to index 2 and 3
++++++++++          #Increment index 1 to <newline>
>>                  #Move to index 3
+++++++++++++       #Increment index 3 to <dash>    
>                   #Move to (empty) index 4
+                   #Increment to start the main loop
[                   #Main loop
,                   #Read first number to index 4
[->+>+<<]>>[-<<+>>] #Copy index 4 to index 5 (index 5 can now be altered)
,                   #Read second number (the number pair is now stored at index 5 and 6)
<                   #Move to first number (index 5)
[->-<<<<.>>>]       #Decrement index 5 and 6 and print <space> until index 5 equals zero
>                   #move to second input (index 6)
[-<<<.>>>]          #Decrement index 6 and print <dash> until index 6 equals zero
<<<<<.>>>           #Print <newline> and move to index 4 (original first number)
]                   #End of main loop
```
*\*(You won't be able to compile/run this due to the comments)*
[Answer]
# Pyth, ~~36~~ ~~22~~ ~~19~~ 14 bytes
This is my first Pyth program. Jakube helped golf out 5 bytes!
```
FNQ<s*V" -"NeN
```
It expects input in the form `[[5,20], [5,20], [2,10], [15,19]]`.
You can [try it online](https://pyth.herokuapp.com/?code=FNQ%3Cs*V%22+-%22NeN&input=%5B%5B5%2C20%5D%2C+%5B5%2C20%5D%2C+%5B2%2C10%5D%2C+%5B15%2C19%5D%5D&debug=0).
[Answer]
# C++14, 69 bytes
```
[]{int a,b;for(;cin>>a>>b;){cout<<setw(b)<<string(b-a,'-')+'\n';}}();
```
First time golfing, this was a good problem to start with!
[Answer]
# K, 18 bytes
```
`0:" -"@{&x,y-x}.'
```
Expects a list of pairs as input:
```
  `0:" -"@{&x,y-x}.'(0 7;5 6;3 6)
-------
     -
   ---
  `0:" -"@{&x,y-x}.'(5 20;5 20;2 10; 15 19)
     ---------------
     ---------------
  --------
               ----
  `0:" -"@{&x,y-x}.'()
```
I unpack each (`'`) tuple using dot-apply (`.`) so that inside the lambda I have access to the start and end value as `x` and `y`, respectively. Then I reassemble these into a (start,length) tuple (`x,y-x`) and apply "where" (`&`). This gives me output like so:
```
  {&x,y-x}.'(0 7;5 6;3 6)
(1 1 1 1 1 1 1
 0 0 0 0 0 1
 0 0 0 1 1 1)
```
Then I simply have to index into a 2-character array using this ragged matrix (`" -"@`) and send it all to stdout (`0:`).
[Answer]
# JavaScript (*ES6*), 63
*Edit* 3 byte saved thx @apsillers  
63 bytes not counting the assignment to F as an anonymous function is allowed.
~~A function with a variable number of parameters, as requested.~~  
A function with a list of tasks as a single parameter.
Test running the snippet below (being EcmaScript 6, Firefox only)
```
F=l=>l.map(t=>console.log(' '.repeat(l=t[0])+'-'.repeat(t[1]-l)))
// TEST
// for this test, redefine console.log to have output inside the snippet
console.log = (...x) => O.innerHTML += x + '\n';
console.log('* Empty'); F([]);
console.log('\n* [0,7],[5,6],[3,6]'); F([[0,7],[5,6],[3,6]])
console.log('\n* [5,20],[5,20],[2,10],[15,19]');F([[5,20],[5,20],[2,10],[15,19]]);
```
```
<pre id=O></pre>
```
[Answer]
# Scala, ~~67~~ ~~63~~ 59 bytes
```
(r:Seq[(Int,Int)])⇒for((s,e)←r)(println(" "*s+"-"*(e-s)))
```
Usage:
 `res0()` or `res0(Seq(28->35, 34->40, 39->44))` etc.
Thanks gilad for shaving 4 bytes using a for expression!
[Answer]
# Ruby: 35 characters
```
->*t{t.map{|s,e|puts' '*s+?-*(e-s)}
```
Sample run:
```
irb(main):001:0> ->*t{t.map{|s,e|puts' '*s+?-*(e-s)}}.call [0,7], [5,6], [3,6]
-------
     -
   ---
```
Updated to accept multiple two-element arrays, one for each task to display. (I think that is what the updated requirement expects.)
[Answer]
**Javascript(ES6), 61/66 chars**
My answer is almost similar to the one posted by @edc65 , but with some improvements.
As tasks in single array are not allowed(so function would be called like this: `a([3,4], [7,15], [0,14], [10, 15])`), correct one would be this(**66 chars** without name assignment):
```
a=(...x)=>x.map(([c,d])=>console.log(' '.repeat(c)+'-'.repeat(d-c)))
```
And if one array argument is allowed(so fn call like this: `a([[3,4], [7,15], [0,14], [10, 15]])`), then it would be(**61 char** without assignment):
```
a=x=>x.map(([c,d])=>console.log(' '.repeat(c)+'-'.repeat(d-c)))
```
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), 12 bytes
```
↑('-'\⍨≤∘⍳)/
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v8/7VHbhEdtEzXUddVjHvWueNS55FHHjEe9mzX1wXITNYwsFIxNNTWMTRRMDICUpYKJiSaXFleagoGC0aPeLQYgNkidgYK5poapghlQDZCAiZoqGBloQkkjBUMgaWiqYGipCQA "APL (Dyalog Classic) – Try It Online")
APL has no varargs, so the arg here is a single Nx2 matrix.
[Answer]
# SWI-Prolog, 55 bytes
```
a([[A,B]|C]):-tab(A),writef("%r",[-,B-A]),nl,C=[];a(C).
```
Example: `a([[5,20],[5,20],[2,10],[15,19]]).` outputs
```
     ---------------
     ---------------
  --------
               ----
```
[Answer]
# Haskell, 76 bytes
```
(#)=replicate
f i=putStr$g=<<(read$'[':i++"]")
g(s,e)=s#' '++(e-s)#'-'++"\n"
```
Input format is a string of comma separated tuples, e.g. `"(1,2),(3,4)"`.
Usage examples:
```
*Main> f "(1,2),(3,4)" 
  -
    -
*Main> f "(0,7),(5,6),(3,6)" 
-------
     -
   ---
```
How it works: for input parsing I enclose the input string in `[` and `]` and use Haskell's native `read` function for lists of integer tuples. The rest is easy: for each tuple `(s,e)` take `s` spaces followed by `e-s` dashes followed by a newline and concatenate all into a single string. Print. 
# Haskell, 59 bytes
with relaxed input format:
```
(#)=replicate
f=putStr.(g=<<)
g(s,e)=s#' '++(e-s)#'-'++"\n"
```
Now it takes a list of tuples, e.g `f [(0,7),(5,6),(3,6)]`.
Works as described above, but without input parsing.
[Answer]
# Julia, 44 bytes
```
x->for t=x a,b=t;println(" "^a*"-"^(b-a))end
```
This creates an anonymous function that accepts an array of tuples as input and prints to STDOUT.
Ungolfed + explanation:
```
function f(x)
    # Loop over the tasks (tuples) in x
    for t in x
        # Assign a and b to the two elements of t
        a,b = t
        # Print a spaces followed by b-a dashes on a line
        println(" "^a * "-"^(b-a))
    end
end
```
Examples:
```
julia> f([(5,20), (5,20), (2,10), (15,19)])
     ---------------
     ---------------
  --------
               ----
julia> f([(0,7), (5,6), (3,6)])
-------
     -
   ---
julia> f([])
```
[Answer]
## JavaScript (ES6), ~~106~~ ~~85~~ ~~80~~ 68 bytes
As per the updated requirements, a list of tasks is now acceptable
```
a=>a.reduce((p,v)=>p+=' '.repeat(z=v[0])+'-'.repeat(v[1]-z)+"\n",'')
```
Takes zero or more arguments: **80 bytes**
```
(...a)=>{s='';a.map(v=>s+=' '[r='repeat'](z=v[0])+'-'[r](v[1]-z)+"\n");return s}
```
---
Original attempt, 106 bytes:
```
(...a)=>{for(i=-1,s='',r='repeat';a.length>++i;){s+=' '[r](a[i][0])+'-'[r](a[i][1]-a[i][0])+"\n"}return s}
```
[Answer]
## C: 108 bytes
```
void g(int*l){for(int c=0;*l>=0;c=!c,l++){if(!c)l[1]-=*l;while(l[0]-->0)putchar(c?45:32);c?putchar(10):0;}}
```
Ungolfed:
```
void gantt(int*l) {
    for (int c = 0; *l >= 0; c = !c, l++) {
        if (!c) l[1] -= *l;
        while (l[0]-- > 0) putchar(c? 45 : 32);
        c? putchar(10) : 0;
    }
}
```
Takes as a parameter a list of integers terminated by `-1`. For example:
```
int list[] = {
    28, 35,
    34, 40,
    39, 44,
    -1
};
gantt(list);
```
It uses `c` to toggle between writing spaces and dashes.
[Answer]
# Perl: ~~42~~ 41 characters
Just to have at least one solution with string parsing too.
```
s!(\d+)->(\d+),?!$"x$1."-"x($2-$1).$/!ge
```
Sample run:
```
bash-4.3$ perl -pe 's!(\d+)->(\d+),?!$"x$1."-"x($2-$1).$/!ge' <<< '0->7,5->6,3->6'
-------
     -
   ---
```
[Answer]
# Java 8, ~~280~~ ~~275~~ ~~246~~ ~~204~~ ~~195~~ ~~185~~ 180 bytes
```
void g(String t){for(String s:t.split(",")){String[]a=s.split("->");s="";Integer i;for(i=0;i<i.valueOf(a[0]);i++)s+=" ";for(;i<i.valueOf(a[1]);i++)s+="-";System.out.println(s);};};
```
A method that takes a comma-seperated input string and prints the resulting ascii Gantt Chart to stdout.
Thanks to durron597 and masterX244 for helping me save 10 bytes
[Answer]
# Java, 187 181 197 183 101 bytes
```
void g(int[][]g){for(int[]i:g)for(int j=0;j<i[1];System.out.print(j++<i[0]?" ":j==i[1]?"-\n":"-"));}
```
Ungolfed (sort of):
```
void g(int[][] g){
    for(int[] i : g)
        for(int j = 0; j < i[1]; System.out.print(j++ < i[0] ? " " : j == i[1] ? "-\n" : "-"));
}
```
Accepts input as 2d array of `int`s. Thanks to [masterX244](https://codegolf.stackexchange.com/users/10801/masterx244) for pointing out that this is allowed by the rules.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 13 9 bytes
```
ạ\⁾ -xµ€Y
```
[Try it online!](https://tio.run/##y0rNyan8///hroUxjxr3KehWHNr6qGlN5P///6OjTXUUjAxidRQQDCMdBUMwwxAoZGgZGwsA "Jelly – Try It Online")
Takes input as `[[5, 20], [5, 20], [2, 10], [15, 19]]`.
-4 bytes thanks to Erik
[Answer]
# JavaScript (ES8), 54 bytes
```
a=>a.map(([x,y])=>"-".repeat(y-x).padStart(y)).join`
`
```
[Try it online](https://tio.run/##NcexCoMwEADQvZ/hdAeXoxEcOsSf6BgCHhqLYpMQg@jXp@3Q6fFWOWQf85KKCnHydTZVTC/8lgRgT7ocmr5RDWefvBS41ImcZHoWyd8h8hqXMNyGOsawx83zFl8wg7UdtXdHf1rSP3RH@uEcYv0A)
[Answer]
# PowerShell 3.0, ~~48~~36 Bytes
```
$args|%{" "*$_[0]+"-"*($_[1]-$_[0])}
```
Thanks to Mazzy for saving 12 with a better way to pass in the list
Old code and explanation:
```
&{param($b="")$b|%{" "*$_[0]+"-"*($_[1]-$_[0])}}
```
Takes arguments as a list of tuples, e.g. (5,20),(5,20),(2,10),(15,19). Had to default $b to a value to take care of the empty string because it somehow entered the foreach block when called with no input.
[Answer]
# [R](https://www.r-project.org/), ~~117 90~~ 75 bytes
```
function(y)for(i in 1:ncol(y))cat(" "<y[1,i],"-"<diff(y)[i],"
")
"<"=strrep
```
[Try it online!](https://tio.run/##NYlBCsIwEADPzSvCnnZhCybQg5L@wlvxUKILC5pIjJC@PlbB0zAzpcvc5Z1i1ZxwI8kF1Wqy7pRivu@F4loRLIRtcawXhhHCVUX2tXzVABkIML9qKbdnbzaMtuJjrUUbRpzYH9gMw5@e3Y9uYnckZs9nIiPYqH8A "R – Try It Online")
Giuseppe golfed at least 29 bytes off my original answer!
The idea is straightforward: print as many `" "` as necessary followed by as many `"-"` as required. Input is a `2*L` matrix with L the number of pairs. The vectorized function `diff` is used to get the number of "-".
[Answer]
# [K (ngn/k)](https://gitlab.com/n9n/k), 13 bytes
```
{" -"@&-':x}'
```
[Try it online!](https://tio.run/##y9bNS8/7/z/NqlpJQVfJQU1X3aqiVv1/iVW1SnRlXZFVmkKFdUJ@trVGQlpiZo51hXWldZFmbC1XSbSBso6igbWGZiyQrWGgYG5tqmBmbaxgpsmloKChpAsBSkCOgpICCCDYIHGINlMFIwNrMGGkYGhgbWiqYGgJ0Q/RggqQDcMug0UlAuhC7P0PAA "K (ngn/k) – Try It Online")
`{` `}` function with argument `x`
`{` `}'` apply to each - in this case to each pair of numbers from the input
`-':` subtract each prior - transform `(a;b)` into `(a;b-a)`
`&` "where" - transform `(a;b-a)` into a list of `a` zeroes followed by `b-a` ones
`" -"@` use as indices in `" -"`
[Answer]
# VBA (Excel), ~~99~~ 90 bytes
Using Immediate Window and `[A1]` as input eg.`0-1,2-5`
Thanks to @TaylorSott for cutting some bytes.
```
b=Split([A1]):For x=0To Ubound(b):c=Split(b(x),"-"):?Spc(c(0)-0)String(c(1)-c(0),"-"):Next
```
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal) `j`, 9 bytes
```
ƛ÷ε\-*nt↳
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=j&code=%C6%9B%C3%B7%CE%B5%5C-*nt%E2%86%B3&inputs=%5B%20%5B0%2C7%5D%20%2C%20%5B5%2C6%5D%2C%20%5B3%2C6%5D%20%5D&header=&footer=) Expects a list of lists.
```
ƛ         # Map each pair to...
 ÷ε       # Their difference
   \-*    # -s
      nt↳ # Padded to the length of the second. 
```
[Answer]
## CoffeeScript, ~~104~~ 82, 65 bytes
List of tasks (ES6): **65 bytes**
```
(a)->a.map (v)->console.log ' '.repeat(v[0])+'-'.repeat v[1]-v[0]
```
List of tasks (ES5 variant): **82 bytes**
```
(a)->a.map (v)->j=-1;s='';s+=(if j<v[0]then' 'else'-') while++j<v[1];console.log s
```
Zero or more arguments: **104 bytes**
```
()->[].slice.call(arguments).map((v)->j=-1;s='';s+=(if j<v[0]then' 'else'-')while++j<v[1];console.log s)
```
Unminified:
```
() -> [].slice.call(arguments).map( # convert to array-like arguments to array and loop
 (v) ->
  j = -1 # counter
  s = '' # initialize string
  s += (if j < v[0] then ' ' else '-') while ++j < v[1]
  console.log s # print to STDOUT
)
```
[Answer]
## PHP, ~~94~~ 91 bytes
Takes a list of tasks (e.g. `[[5,20],[5,20],[2,10],[15,19]]`). Thanks @IsmaelMiguel for the reminder of variable function names.
```
function x($a){$r=str_repeat;foreach($a as$v){echo$r(' ',$v[0]).$r('-',$v[1]-$v[0])."\n";}}
```
---
Original attempt: 94 bytes
```
function x($a){foreach($a as$v){echo str_repeat(' ',$v[0]).str_repeat('-',$v[1]-$v[0])."\n";}}
```
[Answer]
# PHP, 89 characters (function body)
```
function gantt($x){array_walk($x,function($a){echo str_pad(str_repeat('-',$a[1]-$a[0]),$a[1],' ',0)."\n";});}
```
I was going to go for reading strings, but as a lot of the entries were taking arrays of integer pairs, I figured I would follow suit for the sake of brevity.
For each tuple `$a` in array `$x` I echo a string of dashes repeated `$a[1] - $a[0]` times, padded up to the larger number `$a[1]` with spaces. Then the obligatory newline.
[Answer]
# [Gema](http://gema.sourceforge.net/): 47 characters
```
<D>-\><D><y>=@left{$1;}@repeat{@sub{$2;$1};-}\n
```
Sample run:
```
bash-4.3$ gema '<D>-\><D><y>=@left{$1;}@repeat{@sub{$2;$1};-}\n' <<< '0->7,5->6,3->6'
-------
     -
   ---
```
]