read-eval-print-loop

How to reload a clojure file in REPL

江枫思渺然 提交于 2019-11-26 22:28:16
问题 What is the preferred way of reloading functions defined in a Clojure file without having to restart the REPL. Right now, in order to use the updated file I have to: edit src/foo/bar.clj close the REPL open the REPL (load-file "src/foo/bar.clj") (use 'foo.bar) In addition, (use 'foo.bar :reload-all) does not result in required effect, which is evaluating the modified bodies of functions and returning new values, instead of behaving as the source haven't changed at all. Documentation: load

How do I start the REPL in a user defined namespace?

天大地大妈咪最大 提交于 2019-11-26 21:47:51
问题 Writing (in-ns 'dbx) to a file and loading it isn't changing the default namespace of the repl (using cygwin/console). The namespace is still user=> , not dbx=> . vikrant[28] clj Clojure 1.3.0 user=> (load-file "try1.clj") #(Namespace dbx) user=> How can we start the REPL in a namespace defined in a script file? 回答1: java -cp .;clojure-1.3.0.jar; clojure.main -e \ "(ns dbx) (clojure.main/repl) (in-ns 'dbx) (clojure.core/use 'clojure.core)" 回答2: Nowadays is :repl-options {:init-ns foo.bar} .

Source only part of a file

别说谁变了你拦得住时间么 提交于 2019-11-26 20:56:57
问题 My R workflow is usually such that I have a file open into which I type R commands, and I’d like to execute those commands in a separately opened R shell. The easiest way of doing this is to say source('the-file.r') inside R. However, this always reloads the whole file which may take considerable time if big amounts of data are processed. It also requires me to specify the filename again. Ideally, I’d like to source only a specific line (or lines) from the file (I’m working on a terminal

Swift REPL: how to import, load, evaluate, or require a .swift file?

血红的双手。 提交于 2019-11-26 20:48:58
问题 In the Swift REPL, how to import (a.k.a. load, evaluate, require) a typical text *.swift file? I want to use the code from this file: ~/src/Foo.swift Syntax like this doesn't work: import ~/src/Foo.swift For comparison: An equivalent solution in the Swift REPL for a framework is: import Foundation An equivalent solution in the Ruby REPL for a *.ruby file is: require "~/src/foo" These are similar questions that are /not/ what I'm asking: How to use/make a Swift command-line script, executable,

automatically disable a global minor mode for a specific major mode

喜夏-厌秋 提交于 2019-11-26 17:44:41
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 hook, but it has no effect. The variable doesn't change. (eval-after-load "slime" (progn (add-hook 'slime

Scala repl throws error

和自甴很熟 提交于 2019-11-26 15:57:43
问题 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

How to use third party libraries with Scala REPL?

核能气质少年 提交于 2019-11-26 15:57:00
问题 I've downloaded Algebird and I want to try out few things in the Scala interpreter using this library. How do I achieve this? 回答1: 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

How can I use swift in Terminal?

核能气质少年 提交于 2019-11-26 12:34:29
问题 I read What\'s new in Xcode 6. The article introduces some new feature about Xcode 6, and it says: Command Line Xcode’s debugger includes an interactive version of the Swift language, known as the REPL (Read-Eval-Print-Loop). Use Swift syntax to evaluate and interact with your running app or write new code in a script-like environment. The REPL is available from within LLDB in Xcode’s console, or from Terminal. I want to know how to get the REPL? 回答1: sudo xcode-select -switch /Applications

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

旧时模样 提交于 2019-11-26 12:08:01
问题 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 回答1: 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,

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

牧云@^-^@ 提交于 2019-11-26 11:56:31
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 part of a page, it works fine. It's because the "printCounter()" function itself returns undefined . That's