Re: [julia-users] Re: Input a data from the console

2016-10-28 Thread Ismael Venegas Castelló
IMO the parametric method with multiple dispatch is more Julian.

Re: [julia-users] Re: Input a data from the console

2016-10-27 Thread Jeffrey Sarnoff
or, the more specific function read_integer(prompt::String="")::Int print(prompt) str = chomp(readline()) return parse(Int, str) end On Friday, October 28, 2016 at 1:17:54 AM UTC-4, Jeffrey Sarnoff wrote: > > with Yichao's help, > > > > typealias ParseableNumber Union{Float64, Float32,

Re: [julia-users] Re: Input a data from the console

2016-10-27 Thread Jeffrey Sarnoff
with Yichao's help, typealias ParseableNumber Union{Float64, Float32, Signed, Unsigned, Bool} """ `input{T<:ParseableNumber}(::Type{T}, prompt::String="")::T` Read an integer or a floating point value from STDIN. The prompt string, if given, is printed to standard output without a trail

Re: [julia-users] Re: Input a data from the console

2016-10-27 Thread Jeffrey Sarnoff
Thank you, that is helpful. On Friday, October 28, 2016 at 12:22:37 AM UTC-4, Yichao Yu wrote: > > On Fri, Oct 28, 2016 at 12:01 AM, Jeffrey Sarnoff > > wrote: > > And although readline() yields a String, if you are asking for, say, a > Int > > or a Float64 value, you can add a second version

Re: [julia-users] Re: Input a data from the console

2016-10-27 Thread Yichao Yu
On Fri, Oct 28, 2016 at 12:01 AM, Jeffrey Sarnoff wrote: > And although readline() yields a String, if you are asking for, say, a Int > or a Float64 value, you can add a second version of `input`: > > ``` > typealias ParseableNumber Union{Float64, Float32, Signed, Unsigned, Bool} > > """ > `in

[julia-users] Re: Input a data from the console

2016-10-27 Thread Jeffrey Sarnoff
And although readline() yields a String, if you are asking for, say, a Int or a Float64 value, you can add a second version of `input`: ``` typealias ParseableNumber Union{Float64, Float32, Signed, Unsigned, Bool} """ `input{T<:ParseableNumber}(::Type{T}, prompt::String="")::T` Read an int

[julia-users] Re: Input a data from the console

2016-10-27 Thread Ismael Venegas Castelló
""" `input(prompt::String="")::String` Read a string from STDIN. The trailing newline is stripped. The prompt string, if given, is printed to standard output without a trailing newline before reading input. """ function input(prompt::String = "")::String print(prompt) return chomp(r

[julia-users] Re: Input a data from the console

2016-10-27 Thread Tomas Mikoviny
it will be read as a string so you can skip the quotes.. to remove the ballast (single trailing newline from a string) use "chomp" function julia> user_input = chomp(readline()); asd julia> user_input "asd" On Thursday, October 27, 2016 at 5:16:25 PM UTC+2, Aleksandr Mikheev wrote: > > Hello,

[julia-users] Re: Input a data from the console

2016-10-27 Thread Aleksandr Mikheev
Okay, I accidentally figured the answer for the P.S. by myself. четверг, 27 октября 2016 г., 18:16:25 UTC+3 пользователь Aleksandr Mikheev написал: > > Hello, > > How could I input a data from the console? For instance, I would like to > make such that user is able to input the value of x. Is t