read-eval-print-loop

Why is UInt64 max equal -1 in Swift?

大兔子大兔子 提交于 2019-12-19 20:49:11
问题 Using Swift, wether in terminal or playground, when I enter the following on a new line: UInt64.max I get a result value of -1. Is this a bug? Edit: Examples $ xcrun swift Welcome to Swift! Type :help for assistance. 1> UInt64.max / 2 $R1: UInt64 = 9223372036854775807 2> UInt64.max / 2 + 1 $R2: UInt64 = -9223372036854775808 3> UInt64.max $R3: UInt64 = -1 4> println(UInt64.max / 2) 9223372036854775807 5> println(UInt64.max / 2 + 1) 9223372036854775808 6> println(UInt64.max)

VS2015 C# interactive: error CS7069: Reference to type 'Object' claims it is defined in 'System.Runtime', but it could not be found

空扰寡人 提交于 2019-12-19 18:58:06
问题 I just updated to VS2015 Update 2, and started playing around with the C# interactive window. I wanted to use a static method in a static class in one of my .NET 4.0 targeted library projects, so I right-clicked on the project in Solution Explorer, and selected Initialize Interactive with Project . The output in the interactive window looks like this (I replaced some of the full paths with '..' for brevity): #reset Resetting execution engine. Loading context from 'CSharpInteractive.rsp'. #r "

VS2015 C# interactive: error CS7069: Reference to type 'Object' claims it is defined in 'System.Runtime', but it could not be found

久未见 提交于 2019-12-19 18:57:07
问题 I just updated to VS2015 Update 2, and started playing around with the C# interactive window. I wanted to use a static method in a static class in one of my .NET 4.0 targeted library projects, so I right-clicked on the project in Solution Explorer, and selected Initialize Interactive with Project . The output in the interactive window looks like this (I replaced some of the full paths with '..' for brevity): #reset Resetting execution engine. Loading context from 'CSharpInteractive.rsp'. #r "

Evaluate string command in Scala from REPL

北慕城南 提交于 2019-12-19 09:01:02
问题 Is there a way to evaluate a arbitrary string from Scala as if the same text was entered into the Scala REPL directly? I mean, I would like to do something like this: scala> eval("val x = 42") scala> x res2: Int = 42 Since the Scala REPL is accepting commands in an eval loop using jline (I believe) and then compiling/interpreting it, there has to be a way to submit an arbitrary line of text. I am willing to hack the Scala REPL if necessary. 回答1: No REPL hacking necessary—just switch to power

If a Julia script is run from the command line, does it need to be re-compiled every time?

南笙酒味 提交于 2019-12-19 03:14:22
问题 I've read through quite some documentation and questions but I'm still confused about this. In the Profiling section of the documentation it's suggested to first run the target function in the REPL once, so that it's already compiled before being profiled. However, what if the script is fairly complicated and is inteded to be run in the command line, taking arguments? When the julia process finishes and I run the script the second time, is the compilation performed again? Posts like https:/

What is the difference between a REPL and an interpreter?

不羁岁月 提交于 2019-12-19 02:49:39
问题 Is there any technical difference between a REPL and an interpreter? 回答1: Interactive interpreters use REPLs. An interpreter is not required to have one. You can run Python, for example, in non-interactive mode (on a file) and it will not use a read-eval-print loop. 来源: https://stackoverflow.com/questions/3424756/what-is-the-difference-between-a-repl-and-an-interpreter

How can I access the last result in Scala REPL?

爷,独闯天下 提交于 2019-12-18 18:49:45
问题 In python REPL I can do things like: >>> [1,2,3,4] [1, 2, 3, 4] >>> sum(_) 10 In clojure REPL I can do this: user=> "Hello!" "Hello!" user=> *1 "Hello!" Is there is something like this in Scala REPL? 回答1: Yes, you can use dot notation to refer to the last result: scala> List(1,2,3,4) res0: List[Int] = List(1, 2, 3, 4) scala> .sum res1: Int = 10 回答2: You can refer to the previous output as res N for some N . You've probably noticed that in the Scala REPL, results are printed in the form res N

How does orElse work on PartialFunctions

久未见 提交于 2019-12-18 15:58:25
问题 I am getting very bizarre behavior (at least it seems to me) with the orElse method defined on PartialFunction It would seem to me that: val a = PartialFunction[String, Unit] { case "hello" => println("Bye") } val b: PartialFunction[Any, Unit] = a.orElse(PartialFunction.empty[Any, Unit]) a("hello") // "Bye" a("bogus") // MatchError b("bogus") // Nothing b(true) // Nothing makes sense but this is not how it is behaving and I am having a lot of trouble understanding why as the types signatures

How can you dump contents of Clojure REPL to a file?

六眼飞鱼酱① 提交于 2019-12-18 13:16:31
问题 So I have been working on a Clojure tutorial and it's pretty fun so far. Unfortunately, every time I close my REPL out, I lose all of the defn and def that I created in the previous session. So, to save time in the future, is it possible to have the Clojure REPL save everything I've typed to a file so I can dig out what I need for future uses? 回答1: I think most people work by using their IDE to send fragments of code to the REPL, rather than doing a lot of direct hacking in the REPL. This way

node js interact with shell application

拥有回忆 提交于 2019-12-18 12:35:29
问题 There are plenty of node js examples on online about how to spawn a child process and then catch the result as a string for your own processing. But... I want to 'interact' with a child process. For example, how would I write a node js application than starts by calling ' python ' and then types a statement ' 1+1 ', lets me catch the result ' 2 ', before proceeding to type another arbitrary statement ' 4+4 '? (And by 'type' I'm assuming it will require streaming data to the stdin that the