read-eval-print-loop

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

纵饮孤独 提交于 2019-12-05 03:51:17
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 ? Lee 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 a Swift REPL in Cocoa programs

落花浮王杯 提交于 2019-12-05 02:11:42
问题 I can attach LLDB to a program written in Swift and access the REPL, either from within Xcode or by running: lldb -n ProcessName (lldb) repl 1> However, if I attach LLDB to a process which doesn't have the Swift runtime, the REPL isn't very useful. For example: lldb -n Finder Process 218 stopped Executable module set to "/System/Library/CoreServices/Finder.app/Contents/MacOS/Finder". Architecture set to: x86_64-apple-macosx. (lldb) repl 1> import Cocoa error: Couldn't lookup symbols: __swift

Can I stop the execution of an infinite loop in Scala REPL?

拜拜、爱过 提交于 2019-12-04 23:47:07
Can I stop the execution of an infinite loop in Scala REPL? Type this and try to stop it without quitting the REPL. while(true){} I thought something like Ctrl-C would work. It depends on your scala version. If you are already on scala 2.9 it will work by just using CTRL-C. It might take some time untile the command reaches the REPL but it will abort your infinite loop at some time. If you are on an older version of scala (before 2.9). There is no way to stop execution. On those versions CTRL-C will lead to termination of the whole scala REPL. The change was introduced with Scala 2.9.0.RC2.

Scala REPL: How to find function type?

牧云@^-^@ 提交于 2019-12-04 18:22:08
问题 In Scala REPL one can find value types: scala> val x = 1 x: Int = 1 scala> :t x Int Yet Scala REPL does not show the type information for functions: scala> def inc(x:Int) = x + 1 inc: (x: Int)Int scala> :t inc <console>:9: error: missing arguments for method inc; follow this method with `_' if you want to treat it as a partially applied function inc ^ <console>:9: error: missing arguments for method inc; follow this method with `_' if you want to treat it as a partially applied function inc ^

Is there a way in Visual Studio 2012 to use F# REPL when debugging c#

烂漫一生 提交于 2019-12-04 11:13:52
问题 If I have a breakpoint in a c# program I would love to use the F# REPL to inspect my code. Is this possible in any way? 回答1: You should be able to debug a C# project with the F# REPL -- I do it when debugging F# library projects, but C# applications/libraries will work too (I think). Compile your C# project. In F# interactive, reference the C# assembly using the #r directive (see ArthurFSharp's post). Insert a breakpoint somewhere in your C# code. In Visual Studio, go to Tools -> Attach to

octave: load many functions from single file

允我心安 提交于 2019-12-04 10:44:01
问题 How can I put multiple functions in one file and later get access to all of them in the octave interpreter ? I don't want to have a thousand files and want to group functions together. I'd like something like 'import' in python. 回答1: What you're looking for is called “script files”, defined there: http://www.gnu.org/software/octave/doc/interpreter/Script-Files.html 回答2: Once you have saved all your function definitions in a single script file, use source("filename") to have access to these

How to make sbt `console` use -Yrepl-sync?

青春壹個敷衍的年華 提交于 2019-12-04 10:36:58
问题 New in Scala 2.9.1 is the -Yrepl-sync option, which prevents each REPL line from being run in a new thread: scala -Yrepl-sync When I run console from sbt, how do I have it pass this in? 回答1: Short answer: set scalacOptions in (Compile, console) += "-Yrepl-sync" How to discover this: ~/code/scratch/20110930 sbt [info] Loading global plugins from /Users/jason/.sbt11/plugins [info] Set current project to default-9c7c16 (in build file:/Users/jason/code/scratch/20110930/) > inspect console [info]

How can I start an interactive console for VBS?

微笑、不失礼 提交于 2019-12-04 09:00:50
Very similar to this question: How can I start an interactive console for Perl? I just want to be able to start entering VBS statements, one at a time, and have them evaluated straight away, like Python's IDLE. Ansgar Wiechers I wrote this a couple years ago. It's based on this blog post (archived here ), but with a couple enhancements. Essentially it's a REPL (Read, Execute, Print, Loop) using the Execute statement: Do While True WScript.StdOut.Write(">>> ") line = Trim(WScript.StdIn.ReadLine) If LCase(line) = "exit" Then Exit Do On Error Resume Next Execute line If Err.Number <> 0 Then

How can I use a javascript library on the server side of a NodeJS app when it was designed to run on the client?

非 Y 不嫁゛ 提交于 2019-12-04 05:29:17
I'm diving into NodeJS and Express (it's sooo complicated to me) to build a real-time web app. At the moment, I'm trying to understand how I can use an existing javascript library on the server side. The problem is the library appears to be designed to run on the client side and, as a result, the instructions only show you how to use it on the client side. The library I'm talking about can be found here... https://github.com/replit/jsrepl Questions: Since a NodeJS web app is built on javascript, is it fair to say I can run any non-gui javascript library on the server side? Can anyone offer

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

不羁的心 提交于 2019-12-04 05:24:17
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. 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 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. Here's an implicit function that will add a simple operator that writes any object as a String to a file. (Note