read-eval-print-loop

Why does babel-node not support module loading in the REPL?

删除回忆录丶 提交于 2019-12-07 16:21:25
问题 It's established that babel-node doesn't support module loading in the REPL. In the documentation it simply says this: Due to technical limitations ES6-style module-loading is not fully supported in a babel-node REPL. My question is why? If I wrote a tiny script named t.js and ran it with babel-node, then import statements would work fine. What is the effective difference between a REPL which reads source code a line at a time from standard in, and babel-node t.js which reads source code from

Import python modules in the background in REPL

◇◆丶佛笑我妖孽 提交于 2019-12-07 13:23:13
问题 Some python modules, notably matplotlib , take a long time to load start = datetime.datetime.now(); import numpy, pandas, matplotlib, sklearn; datetime.datetime.now() - start takes half a second with cached files, and several seconds for non-cached files. Is there a way to load these modules in the background, when in the Python interpreter? 回答1: You can import modules in separate threads. Here is the solution. Create a file load_modules.py : from concurrent.futures import ThreadPoolExecutor

Swallowing user input while running a sub-command

扶醉桌前 提交于 2019-12-07 13:11:12
问题 I'm writing a simple REPL (a command line wrapper for adb ) in Ruby where I support two kinds of commands: interactive commands non-interactive commands As for 2, I simply want to invoke a system command from the REPL, capture its output while it's outputting text, and allow the user to exit back into the REPL from that command. Example: >> logcat ... // log output here ! user hits CTRL-D >> // back at the prompt This is to happen within my program, not the system shell. Now the problem is:

Scala REPL unable to import packge

送分小仙女□ 提交于 2019-12-07 12:40:20
问题 I'm trying to import com.lambdaworks.crypto.SCryptUtil (from crypto) in the Scala REPL. I'm running the REPL from the Java directory containing com/lambdaworks/crypto. The REPL can't find com.lambdaworks.crypto.SCryptUtil , but it can autocomplete up to com.lambdaworks.crypto but can't find anything after that. When I used the REPL in the IntelliJ IDEA after including the package in my project, I was able to find the SCryptUtil class. Am I missing some classpath parameters that are required

CSharpRepl emacs integration?

那年仲夏 提交于 2019-12-07 09:43:47
问题 I happen to know mono's CSharpRepl, are there emacs csharp mode that use this to run REPL in one window, and compile/run the C# code in the other window just like python mode? 回答1: You could just create a lisp function to call the CSharpRepl and assign a key to call it when you're working on C# code. For example, you could put the following in your Emacs init file (assuming the CSharpRepl executable "csharp" is in your PATH): (defun csharp-repl () "Open a new side-by-side window and start

pass results to another command in redis

谁说我不能喝 提交于 2019-12-07 07:38:09
问题 Is there a way to pass the return value of one function to another in Redis? Of course, if you're using a language wrapper (like Ruby), it's easy — but what about from the CLI? e.g. something like this, bash style redis 127.0.0.1:6379> keys student* | mget or something like this redis 127.0.0.1:6379> mget(keys student*) keys student* will return a list of keys, but I've no idea how to fetch all the values for those keys. Thoughts? 回答1: From the CLI, you just have to let the shell do its job.

Why does REPL treat clojure.core/doc as a var?

◇◆丶佛笑我妖孽 提交于 2019-12-07 05:08:13
问题 I'm trying to get documentation using the Clojure doc function, but can't get it recognized from the REPL (I'm using Emacs and SLIME). The following sequence describes what's going on (error message follows immediately after each line): gaidica.core> (doc first) ; Evaluation aborted. Unable to resolve symbol: doc in this context [Thrown class java.lang.Exception] gaidica.core> (clojure.core/doc first) ; Evaluation aborted. No such var: clojure.core/doc [Thrown class java.lang.Exception] user>

Swift REPL: how to save/load the REPL state? (a.k.a. suspend/resume, snapshot, clone)

ε祈祈猫儿з 提交于 2019-12-07 04:37:16
问题 In the Swift REPL, what is a way to preserve the REPL state? For example, I want to do a bunch of work in the REPL, then save it, so I can load it later. This concept might be named save/load, suspend/resume, snapshot/clone, serialize/deserialize, etc. Any solution that gets me toward this will help, even if it's a hack like these: Record all the history lines, then replay them in another REPL. Serialize all the objects, then deserialize them in another REPL. Snapshot the RAM or VM, then

How can I get `ghci` to use my `show` function?

独自空忆成欢 提交于 2019-12-06 22:20:39
问题 Let's say you want to use your own show function (for example, let show = take 1000 . Prelude.show ). How can you allow ghci to use that for printing instead of the built in show ? 回答1: You can define your own interactive print function e.g: module BetterPrint betterPrint a = putStrLn (take 1000 $ show a) then start ghci as ghci -interactive-print=BetterPrint.betterPrint 来源: https://stackoverflow.com/questions/35613612/how-can-i-get-ghci-to-use-my-show-function

Access package private method in Scala REPL

大城市里の小女人 提交于 2019-12-06 18:59:27
Suppose I have a private[stuff] method Stuff.something in org.my.stuff . Is there something that I can do in the Scala REPL so that I can call Stuff.something without getting the error error: value something is not a member of org.my.stuff.Stuff ? In particular, can I get the REPL to be "inside" a given package (here org.my.stuff ), giving access to its private members? Rich Using "packages" in the REPL You cannot get a REPL prompt "inside" a given package, see https://stackoverflow.com/a/2632303/8261 You can use "package" statements inside " :paste -raw " mode in the REPL (see e.g. http:/