read-eval-print-loop

Inferred type in a Scala program

こ雲淡風輕ζ 提交于 2019-12-06 15:53:35
问题 The Scala REPL shows the inferred type of an expression. Is there a way to know the inferred type in a normal Scala program ? For example, val x = { //some Scala expressions } Now I want to know the actual type of x. 回答1: Perhaps TypeTag is what you are looking for? scala> import scala.reflect.runtime.universe._ import scala.reflect.runtime.universe._ scala> def typeOf[T](x:T)( implicit tag: TypeTag[T] ) = tag typeOf: [T](x: T)(implicit tag: reflect.runtime.universe.TypeTag[T])reflect.runtime

What's a REPL process and what can I use it for? [duplicate]

老子叫甜甜 提交于 2019-12-06 12:00:45
This question already has answers here : Closed 7 years ago . This question was migrated from Web Applications Stack Exchange because it can be answered on Stack Overflow. Migrated 7 years ago . Possible Duplicate: Relation between REPL, interpreter and compiler I've been experimenting on heroku.com with node.js and I've heard of a "REPL process" I could use for experimenting in my app’s environment. Could someone give me an overview of what it is, and how it might be applied? jcolebrand REPL - As per the Wikipedia entry It's a Read Eval Print Loop. What that means for you is: It's like a

How can I easily write a REPL app in Java?

情到浓时终转凉″ 提交于 2019-12-06 09:00:20
I have a CMS server that provides a client library. I'd like to be able to drive the CMS interactively from the command line. The basic approach would be: Create a connection to the CMS Add the CMS connection object to the REPL context Connect the REPL to stdout/stderr/stdin Kick off a daemon thread for to keep the REPL running. I was hoping that I could perhaps leverage Groovy to do this but haven't managed to get it working. Is there a library that provides REPL support? Can you provide a simple example? Matthew Farwell If you don't mind using Scala as your language, you can use the Scala

How to get suppress ^M characters in my ClojureBox (EmacsW32) REPL connected to lein swank

梦想与她 提交于 2019-12-06 04:04:38
I am connecting to a swank server from my ClojureBox install. I.e. lein swank from my project directory and then M-x slime-connect from EmacsW32. However, when I do this I see the DOS line-endings everywhere in the REPL ( ^M ). I.e. user> (doc map) -------------------------^M clojure.core/map^M ([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])^M Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are

Scala REPL unable to import packge

耗尽温柔 提交于 2019-12-06 03:26:45
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 for import? The REPL won't compile the Java code for you—it's only autocompleting that far because it

Scala interactive interpreter (REPL) - how to redirect the output to a text file?

喜夏-厌秋 提交于 2019-12-06 02:19:07
问题 Is it possible, and if yes how is it done? The usual > and >> that work on the Windows or Linux command line don't work in this context. 回答1: You can do it programmaticaly from console: import java.io.FileOutputStream import scala.Console Console.setOut(new FileOutputStream("<output file path>")) from now on all print and println would be directed into this file 回答2: It's unclear from your question exactly how you want to use such a thing. An example of what you are trying to do might help.

Node.js: Hooking repl to a remote node server

为君一笑 提交于 2019-12-06 00:34:10
问题 Let's say I have a node server running at mysite.com. Is there a way to set up that server so that I can use node's repl api to securely connect to it from my local machine? 回答1: Well, if you used this example: net.createServer(function (socket) { repl.start("node via TCP socket> ", socket); }).listen(5001, "localhost"); And firewalled that port 5001 , you should be able to securely connect to it using ssh: ssh user@host nc localhost 5001 In this case, the security relies on your firewall,

Import python modules in the background in REPL

。_饼干妹妹 提交于 2019-12-06 00:06:31
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? You can import modules in separate threads. Here is the solution. Create a file load_modules.py : from concurrent.futures import ThreadPoolExecutor import importlib import sys modules_to_load = ['numpy', 'pandas', 'matplotlib'] def do_import(module_name):

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

橙三吉。 提交于 2019-12-05 19:40:57
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 a file? Does anyone know if there are plans to support import in the future, as lack of import kinda

Swallowing user input while running a sub-command

帅比萌擦擦* 提交于 2019-12-05 18:50:45
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: while logcat is running, the parent process (the REPL) keeps capturing keystrokes and then replays (?)