read-eval-print-loop

Is there a way to have node preserve command line history between sessions?

て烟熏妆下的殇ゞ 提交于 2019-11-27 13:37:56
问题 When I run node from the command line with no arguments, I enter an interactive shell. If I execute some commands, exit node, and restart node, the up arrow doesn't do anything (I'd like it scroll through my previous commands). Is there a way I can invoke node interactively such that it will remember my old commands? 回答1: You could use rlwrap to store node.js REPL commands in a history file. First, install rlwrap (done easily with a package manager like apt-get or brew etc). Then add an alias

How to use third party libraries with Scala REPL?

放肆的年华 提交于 2019-11-27 12:32:26
I've downloaded Algebird and I want to try out few things in the Scala interpreter using this library. How do I achieve this? Rüdiger Klaehn Of course, you can use scala -cp whatever and manually manage your dependencies. But that gets quite tedious, especially if you have multiple dependencies. A more flexible approach is to use sbt to manage your dependencies. Search for the library you want to use on search.maven.org . Algebird for example is available by simply searching for algebird . Then create a build.sbt referring to that library, enter the directory and enter sbt console . It will

Scala repl throws error

拟墨画扇 提交于 2019-11-27 12:16:44
When I type scala on the terminal to start the repl, it throws this error scala> [init] error: error while loading AnnotatedElement, class file '/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar (java/lang/reflect/AnnotatedElement.class)' is broken (bad constant pool tag 15 at byte 2713) When I hit enter and type println("hello, world") , it again throws this error: error while loading CharSequence, class file '/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar (java/lang/CharSequence.class)' is broken (bad constant pool tag 15 at byte 1501) I am using Ubuntu 14.04 and java -version gives java version "1.8.0

How to disable “Save workspace image?” prompt in R?

自古美人都是妖i 提交于 2019-11-27 11:10:12
When I exit the interactive R shell, it displays an annoying prompt every time: > > Save workspace image? [y/n/c]: n I'm always answering "no" to it, because if I wished to save my work, I'd do that before trying to exit. How to get rid of the prompt? Note: see ?save.image Joshua Ulrich You can pass the --no-save command line argument when you start R, or you can override the q function: utils::assignInNamespace( "q", function(save = "no", status = 0, runLast = TRUE) { .Internal(quit(save, status, runLast)) }, "base" ) Put the above code in your .Rprofile so it will be run on startup for every

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

我的梦境 提交于 2019-11-27 10:18:37
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 ? 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 in the REPL. Unlike require this pollutes the REPL history with the commands you loaded. However, it has the

Anders Hejlsberg's C# 4.0 REPL

送分小仙女□ 提交于 2019-11-27 10:16:14
问题 During the last 10 minutes of Ander's talk The Future of C# he demonstrates a really cool C# Read-Eval-Print loop which would be a tremendous help in learning the language. Several .NET4 related downloads are already available: Visual Studio 2010 and .NET Framework 4.0 CTP, Visual Studio 2010 and .NET Framework 4 Training Kit. Do you know what happened to this REPL? Is it somewhere hidden among examples? I know about mono repl. Please, no alternative solutions. 回答1: The REPL demo was part of

Clojure : loading dependencies at the REPL

不想你离开。 提交于 2019-11-27 09:41:01
问题 I recently learned (thanks to technomancy) that, at the REPL --- This fails: user=> (:require [clojure.set :as set]) java.lang.ClassNotFoundException: clojure.set (NO_SOURCE_FILE:24) Whereas this succeeds : user=> (require '[clojure.set :as cs]) nil at loading the clojure.set class. Context: The former line was copied from a namespaced source file. My primary question is : What is the change we have made, by swapping the : and ' characters, which now allows for success of the latter command ?

How do I load a file into the python console?

左心房为你撑大大i 提交于 2019-11-27 09:00:09
问题 I have some lines of python code that I'm continuously copying/pasting into the python console. Is there a load command or something I can run? e.g. load file.py 回答1: For Python 2 (see other answers for Python 3) give this a try: execfile('file.py') Example usage: C:\junk>copy con execfile_example.py a = [9, 42, 888] b = len(a) ^Z 1 file(s) copied. C:\junk>\python27\python Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits"

Output difference between ipython and python

随声附和 提交于 2019-11-27 08:12:59
问题 It was my understanding that python will print the repr of the output, but this is apparently not always the case. For example: In ipython: In [1]: type([]) Out[1]: list In [2]: set([3,1,2]) Out[2]: {1, 2, 3} In python: >>> type([]) <type 'list'> >>> set([3,1,2]) set([1, 2, 3]) What transformation does ipython apply on the output? 回答1: Instead of repr or standard pprint module IPython uses IPython.lib.pretty.RepresentationPrinter.pretty method to print the output. Module IPython.lib.pretty

Can rlwrap use a wrapped command's own TAB completion?

筅森魡賤 提交于 2019-11-27 07:45:34
问题 I want to use rlwrap with a custom erlang repl. It works perfectly if I run it as "rlwrap -a myrepl". The problem is that myrepl has builtin tab completion which gets trampled by rlwrap. I want to make rlwrap to release the TAB key 回答1: You can't use rlwrap 's line editing/history and your repl's TAB completion at the same time. rlwrap provides line editing, history and (very simple) completion for commands that don't have it . A command that has something as fancy as TAB completion shouldn't