Top Level Namespace
Defined in:
Constant Summary
-
EPS =
Real.new(1e-12)
Macro Summary
-
input(ast, *, io = STDIN)
Inputs from io.
- input(*asts, io = STDIN)
- input_column(types, size, *, io = STDIN)
- internal_input(type, else_ast, io)
- internal_input_array(type, args, io)
Macro Detail
macro input(ast, *, io = STDIN)
#
Inputs from io.
Specifications
AST | Example | Expanded code
------------------+---------------------+---------------------------------------
Uppercase string | Int32, Int64, etc. | {}.new(Scanner.s)
| s, c, i, iN, uN | Scanner.{}
| f, big_i, etc. | Scanner.s.to_{}
Call [] | type[size] | Array.new(input(size)) { input(type) }
TupleLiteral | {t1, t2, t3} | {input(t1), input(t2), input(t3)}
ArrayLiteral | [t1, t2, t3] | [input(t1), input(t2), input(t3)]
HashLiteral | {t1 => t2} | {input(t1) => input(t2)}
NamedTupleLiteral | {a: t1, b: t2} | {a: input(t1), b: input(t2)}
RangeLiteral | t1..t2 | input(t1)..input(t2)
Expressions | (exp1; exp2) | (input(exp1); input(exp2);)
If | cond ? t1 : t2 | input(cond) ? input(t1) : input(t2)
Assign | target = value | target = input(value)
Examples
Input:
5 3
foo bar
1 2 3 4 5
n, m = input(Int32, Int64) # => {5, 5i64}
input(String, Char[m]) # => {"foo", ['b', 'a', 'r']}
input(Int32[n]) # => [1, 2, 3, 4, 5]
n, m = input(i, i64) # => {5, 5i64}
input(s, c[m]) # => {"foo", ['b', 'a', 'r']}
input(i[n]) # => [1, 2, 3, 4, 5]
Input:
2 3
1 2 3
4 5 6
h, w = input(i, i) # => {2, 3}
input(i[h, w]) # => [[1, 2, 3], [4, 5, 6]]
input(i[i, i]) # => [[1, 2, 3], [4, 5, 6]]
Input:
5 3
3 1 4 2 5
1 2
2 3
3 1
n, m = input(i, i) # => {5, 3}
input(i.pred[n]) # => [2, 0, 3, 1, 4]
input({i - 1, i - 1}[m]) # => [{0, 1}, {1, 2}, {2, 0}]
Input:
3
1 2
2 2
3 2
input({tmp = i, tmp == 1 ? i : i.pred}[i]) # => [{1, 2}, {2, 1}, {3, 1}]
Input:
3
1 1
2 1 2
5 1 2 3 4 5
n = input(i) # => 3
input(i[i][n]) # => [[1], [1, 2], [1, 2, 3, 4, 5]]
Input:
3
1 2
2 3
3 1
n = input(i)
input_column({Int32, Int32}, n) # => {[1, 2, 3], [2, 3, 1]}