read-eval-print-loop

How to get Python interactive console in current namespace?

风格不统一 提交于 2019-12-02 18:28:06
I would like to have my Python code start a Python interactive console (REPL) in the middle of running code using something like code.interact(). But the console that code.interact() starts doesn't see the variables in the current namespace. How do I do something like: mystring="hello" code.interact() ... and then in the interactive console that starts, I should be able to type mystring and get "hello". Is this possible? Do I need to set the "local" argument of code.interact() to something? What would this be set to? How should it be called? Try: code.interact(local=locals()) (found here: http

Clear terminal window in Node.js readline shell

故事扮演 提交于 2019-12-02 17:46:54
I have a simple readline shell written in Coffeescript: rl = require 'readline' cli = rl.createInterface process.stdin, process.stdout, null cli.setPrompt "hello> " cli.on 'line', (line) -> console.log line cli.prompt() cli.prompt() Running this displays a prompt: $ coffee cli.coffee hello> I would like to be able to hit Ctrl-L to clear the screen. Is this possible? I have also noticed that I cannot hit Ctrl-L in either the node or coffee REPLs either. I am running on Ubuntu 11.04. You can watch for the keypress yourself and clear the screen. process.stdin.on 'keypress', (s, key) -> if key

Attach a clojure / scala repl to a running JVM

纵饮孤独 提交于 2019-12-02 17:32:45
I have a java web application running under tomcat in a Sun java 6 JVM. Is there a way to attach a scala or clojure REPL to the running JVM ? Once the webapp is up and running, the context in which the calls are to be made is already setup in the running VM. Hence, this can be really helpful in invoking arbitrary java method calls for incremental, exploratory development and for debugging. Copied over the answer from the other question as per your request: liverepl: Connect a Clojure REPL to running Java or Clojure processes without any special setup From the website: Start a Clojure REPL

How is Lisp's read-eval-print loop different than Python's?

混江龙づ霸主 提交于 2019-12-02 17:24:22
I've encounter a following statement by Richard Stallman : 'When you start a Lisp system, it enters a read-eval-print loop. Most other languages have nothing comparable to read, nothing comparable to eval, and nothing comparable to print. What gaping deficiencies! ' Now, I did very little programming in Lisp, but I've wrote considerable amount of code in Python and recently a little in Erlang. My impression was that these languages also offer read-eval-print loop, but Stallman disagrees (at least about Python): 'I skimmed documentation of Python after people told me it was fundamentally

mit-scheme REPL with command line history and tab completion

岁酱吖の 提交于 2019-12-02 16:19:43
I'm reading SICP and I'm using mit-scheme installed on my os x 10.8 laptop via homebrew . Everything works as advertised, however I'm spoiled by the ease with which I get tab completion and command line history in REPL's for runtimes like Python and Node.js. I'm not looking for anything heavy duty, but these features are pretty easy to come by in modern REPL's (it's just a simple startup file in Python and can be implemented in a few lines in Node.js ). Is there an easy way to get tab completion and command history in the mit-scheme REPL without a heavy-duty application or having to switch to

How can I avoid the nil printed in the end?

百般思念 提交于 2019-12-02 02:15:37
问题 I have coded this function that prints-out the state of the board, but in the end, due to the fact that there isnt no return the function prints an nil! Function: (defun show-board (board) (dotimes (number 8) (dotimes (number2 8) (let ((pos (aref board number number2))) (cond ((equal pos 0) (format t "~a " "B")) ((equal pos 1) (format t "~a " "P")) (t (format t "~a " "L"))))) (format t "~%"))) A board is an 8x8 array! function call output on command lines: B P B P B P B P P B P B P B P B B P

Node REPL throws SyntaxError: Unexpected identifier

血红的双手。 提交于 2019-12-01 22:39:49
I am very newbie to node.js. In the node REPL everything was working fine. But something changed. When I try to execute a file it shows this... D:\Projects-2015\uniqueva>node />node module.js SyntaxError: Unexpected identifier at Object.exports.createScript (vm.js:44:10) at REPLServer.defaultEval (repl.js:117:23) at bound (domain.js:254:14) at REPLServer.runBound [as eval] (domain.js:267:12) at REPLServer.<anonymous> (repl.js:279:12) at REPLServer.emit (events.js:107:17) at REPLServer.Interface._onLine (readline.js:214:10) at REPLServer.Interface._line (readline.js:553:8) at REPLServer

Trying to understand how classes declared on the REPL are treated internally

吃可爱长大的小学妹 提交于 2019-12-01 20:48:52
I am trying to understand how scoping works in the REPL. I tried following Section 5.1.1 of Joshua Suereth's book Scala in depth.This is on Windows XP, Java 7 and Scala 2.9.1. I declare a class Dinner in the REPL. The binding Dinner exists in the local scope. Then I instantiate because it is locally bound. scala> class Dinner { | val veggie="broccoli" | def announceDinner(veggie: String){ | println("Dinner happens to be tasteless " + veggie + " soup") | } | } defined class Dinner scala> new Dinner res1: Dinner = Dinner@27fb77 So far so good. The name Dinner was bound locally and we could also

Why is UInt64 max equal -1 in Swift?

社会主义新天地 提交于 2019-12-01 18:08:07
Using Swift, wether in terminal or playground, when I enter the following on a new line: UInt64.max I get a result value of -1. Is this a bug? Edit: Examples $ xcrun swift Welcome to Swift! Type :help for assistance. 1> UInt64.max / 2 $R1: UInt64 = 9223372036854775807 2> UInt64.max / 2 + 1 $R2: UInt64 = -9223372036854775808 3> UInt64.max $R3: UInt64 = -1 4> println(UInt64.max / 2) 9223372036854775807 5> println(UInt64.max / 2 + 1) 9223372036854775808 6> println(UInt64.max) 18446744073709551615 I think it is a bug of terminal and playground. But, the output of the println is correct

Accessing command history in QPython console for Android

落花浮王杯 提交于 2019-12-01 16:02:50
Is it possible to access previously entered commands in QPython's console/REPL? Up and down arrows just display escape sequences. I tried switching the Terminal type option between screen , linux , and vt100 , but this doesn't seem to help. A related question didn't specify it was referring to QPython's console, and got an answer that is not relevant. No, it' not possible. The feature hasn't been implemented. But if you can use Python3's syntax instead of Python 2.7, you can use QPython3 app instead where this feature has been implemented. This is the answers from QPython's support: From: