[julia-users] Re: Newbie Question: Command Line Woes
Cedric, Thanks very much. That works for the hello() function, but not exactly for the five() function. For instance, if I have function five() return 5 end five() Then I get no output when calling from the Command Line, while I do in the REPL. In fact, in the REPL I get the output after include("five.jl") and then again when I call five(). That make sense to me. To get output at the Command Line I need to replace "five()" with "println(five())" or change the "return 5" statement to "return println(5)". Why is there the difference in behaviors? It's not a big deal, but it does seem like an inconsistency in how functions behave in the REPL and at the command line. I seem to remember encountering a difference in behavior between the REPL and IJulia. Is there a document the lists the differences in Command Line, REPL, and IJulia environments. Thanks, Rich On Monday, May 9, 2016 at 11:02:43 PM UTC-4, Cedric St-Jean wrote: > > hello.jl defines the hello() function, but you need to call it to get some > output. > > function hello() >println("Hello World") > return > end > > hello() > hello() > > will print "Hello World" twice. > > On Monday, May 9, 2016 at 10:59:05 PM UTC-4, rich2...@gmail.com wrote: >> >> Newbie question: Why don't I get any output from the following programs >> when I run them from the command line on my Macbook pro (OS 10.11.4) or two >> different versions of Linux. Everything works as expected when the programs >> are run in the REPL. >> >> On the Mac I use the following in my PATH. >> >> /Applications/Julia-0.4.5.app/Contents/Resources/julia/bin >> >> Command line: julia hello.jl >> function hello() >> println("Hello World") >> return >> end >> >> Command line: julia five.jl >> function five() >> return 5 >> end >> >> The scripts run fine with no apparent errors or warnings. They just don't >> produce any output. >> >> Thanks, >> Rich >> >
Re: [julia-users] Re: Newbie Question: Command Line Woes
Tom, That makes sense. Thanks. Rich On Tuesday, May 10, 2016 at 11:04:13 AM UTC-4, Tom Breloff wrote: > > Rich: The return values from the REPL are implicitly displayed. To do > this in a script you have to call display(five()), or show/print. It would > be really bad/annoying if every value was printed to the screen during a > script... > > See: http://docs.julialang.org/en/release-0.4/stdlib/io-network/ > > On Tue, May 10, 2016 at 11:00 AM, > > wrote: > >> Cedric, >> Thanks very much. That works for the hello() function, but not exactly >> for the five() function. For instance, if I have >> >> function five() >> return 5 >> end >> five() >> >> Then I get no output when calling from the Command Line, while I do in >> the REPL. In fact, in the REPL I get the output after include("five.jl") >> and then again when I call five(). That make sense to me. To get output at >> the Command Line I need to replace "five()" with "println(five())" or >> change the "return 5" statement to "return println(5)". Why is there the >> difference in behaviors? It's not a big deal, but it does seem like an >> inconsistency in how functions behave in the REPL and at the command line. >> >> I seem to remember encountering a difference in behavior between the REPL >> and IJulia. Is there a document the lists the differences in Command Line, >> REPL, and IJulia environments. >> >> Thanks, >> Rich >> >> On Monday, May 9, 2016 at 11:02:43 PM UTC-4, Cedric St-Jean wrote: >>> >>> hello.jl defines the hello() function, but you need to call it to get >>> some output. >>> >> >>> function hello() >>>println("Hello World") >>> return >>> end >>> >>> hello() >>> hello() >>> >>> will print "Hello World" twice. >>> >>> On Monday, May 9, 2016 at 10:59:05 PM UTC-4, rich2...@gmail.com wrote: Newbie question: Why don't I get any output from the following programs when I run them from the command line on my Macbook pro (OS 10.11.4) or two different versions of Linux. Everything works as expected when the programs are run in the REPL. On the Mac I use the following in my PATH. /Applications/Julia-0.4.5.app/Contents/Resources/julia/bin Command line: julia hello.jl function hello() println("Hello World") return end Command line: julia five.jl function five() return 5 end The scripts run fine with no apparent errors or warnings. They just don't produce any output. Thanks, Rich >>> >
[julia-users] Newbie Question: Command Line Woes
Newbie question: Why don't I get any output from the following programs when I run them from the command line on my Macbook pro (OS 10.11.4) or two different versions of Linux. Everything works as expected when the programs are run in the REPL. On the Mac I use the following in my PATH. /Applications/Julia-0.4.5.app/Contents/Resources/julia/bin Command line: julia hello.jl function hello() println("Hello World") return end Command line: julia five.jl function five() return 5 end The scripts run fine with no apparent errors or warnings. They just don't produce any output. Thanks, Rich