read-eval-print-loop

How do I load my script into the node.js REPL?

旧巷老猫 提交于 2019-11-26 11:53:41
问题 I have a script foo.js that contains some functions I want to play with in the REPL. Is there a way to have node execute my script and then jump into a REPL with all the declared globals, like I can with python -i foo.py or ghci foo.hs ? 回答1: There is still nothing built-in to provide the exact functionality you describe. However, an alternative to using require it to use the .load command within the REPL, like such: .load foo.js It loads the file in line by line just as if you had typed it

Does Go provide REPL?

故事扮演 提交于 2019-11-26 11:47:58
问题 The interactive environment is VERY helpful for a programmer. However, it seems Go does not provide it. Is my understanding correct? 回答1: No, Go does not provide a REPL. However, as already mentioned, Go Playground (this is the new URL) is very handy. The Go Authors are also thinking about adding a feature-rich editor to it. If you want something local, consider installing hsandbox. Running it simply with hsandbox go will split your terminal screen (with screen ) where you can write code at

Is there something like python's interactive REPL mode, but for Java?

南楼画角 提交于 2019-11-26 10:08:23
问题 Is there something like python\'s interactive REPL mode, but for Java? So that I can, for example, type InetAddress.getAllByName( localHostName ) in a window, and immediately get results, without all this public static void nightmare() thing? 回答1: edit Since Java 9 there's JShell Original answer follows You can also use Groovy Console. It is an interactive console where you can do what you want. Since Groovy also includes classes from the core java platform, you'll be able to use those

Non exhaustive pattern in function in GHCi

夙愿已清 提交于 2019-11-26 06:08:23
问题 I want to make a function that displays the last element of a list. This is my code: ghci> let myLast :: [a] -> a ghci> let myLast [] = error ghci> let myLast [x] = x ghci> let myLast (x:xs) = myLast xs And I get the following error: ***Exception: Non-exhaustive patterns in function myLast I understood that you get this error when you\'re missing a case, but I think I have included all the possibilities. Any ideas? 回答1: If you use a let in each line, each definition will make a new function

In Python interpreter, return without “ ' ”

拈花ヽ惹草 提交于 2019-11-26 05:37:30
问题 In Python, how do you return a variable like: function(x): return x Without the \'x\' ( \' ) being around the x ? 回答1: In the Python interactive prompt, if you return a string, it will be displayed with quotes around it, mainly so that you know it's a string. If you just print the string, it will not be shown with quotes (unless the string has quotes in it). >>> 1 # just a number, so no quotes 1 >>> "hi" # just a string, displayed with quotes 'hi' >>> print("hi") # being *printed* to the

automatically disable a global minor mode for a specific major mode

[亡魂溺海] 提交于 2019-11-26 05:34:17
问题 I have centered-cursor-mode activated globaly, like this: (require \'centered-cursor-mode) (global-centered-cursor-mode 1) It works fine, but there are some major modes where I would like to disable it automatically. For example slime-repl and shell. There is another question dealing with the same problem, but another minor mode. Unfortunately the answers only offer workarounds for this specific minor mode (global-smart-tab-mode), that doesn\'t work with centered-cursor-mode. I tried this

Why does this JavaScript code print “undefined” on the console?

人盡茶涼 提交于 2019-11-26 02:39:12
问题 I have following JavaScript code: var counter = 0; function printCounter(){ console.log(\"counter=\" + ++counter); setTimeout(printCounter, 1000); } printCounter(); I expect that it should print this output: counter=1 counter=2 counter=3 ... But instead it prints following: counter=1 undefined // <-- Notice this \"undefined\" counter=2 counter=3 ... Why it prints \"undefined\" after first iteration? Important: I see such behavior only when the code executed in JavaScript console. If it\'s the

Have you used any of the C++ interpreters (not compilers)? [closed]

喜你入骨 提交于 2019-11-26 00:59:01
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I am curious if anyone have used UnderC, Cint, Cling, Ch, or any other C++ interpreter and could share their experience. 回答1: NOTE: what follows is rather CINT specific, but given that its probably the most widely used C++ interpreter it may be valid for them all. As a graduate student in particle physics who's

How to save a Python interactive session?

浪子不回头ぞ 提交于 2019-11-26 00:49:47
问题 I find myself frequently using Python\'s interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don\'t properly save and clean up the useful bits as often as I would like. Is there a way to save my input into the shell (db connections, variable assignments, little for loops and bits of logic) -- some history of the interactive session? If I use something like script I get too much stdout noise. I don\'t really need to pickle all the

Is there an interpreter for C? [closed]

倾然丶 夕夏残阳落幕 提交于 2019-11-25 23:34:15
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. I was wondering if there is something like an interpreter for C. That is, in a Linux terminal I can type in \"python\" and then code in