我正试图退出REPL.
我使用(. System exit 0)
或(System/exit 0)
,但这会导致错误:
Exception in thread "Thread-3" java.lang.RuntimeException: java.lang.IndexOutOfBoundsException
Run Code Online (Sandbox Code Playgroud)
还有另一种退出REPL的方法吗?我该如何解决这个错误?
这是我的问题:我每次打开新的repl时都需要运行一些代码,在Google中搜索我发现我可以使用该文件init.clj
或者user.clj
(与Leiningen一起)
这是我需要运行的代码:
(set! *print-length* 103)
(println "hello")
(println *print-length*)
Run Code Online (Sandbox Code Playgroud)
这些是两个文件的结果:
[~/project]$ lein repl
hello <- this is the println, so the file is excecuted
103 <- this is the println of *print-length* apparently change
REPL started; server listening on localhost port 20875
user=> *print-length*
nil <- but the val of *print-length* don't change
Run Code Online (Sandbox Code Playgroud)
有什么我需要做或做我有一些错误?
谢谢大家!
我有一个文件"myfile.txt",其中包含下一个内容:
hola mundo
hello word
Run Code Online (Sandbox Code Playgroud)
我想要与每一行合作
for i in `cat myfile.txt`; do echo $i; done
Run Code Online (Sandbox Code Playgroud)
我希望这能给我
hola mundo
hello word
Run Code Online (Sandbox Code Playgroud)
先是一条线,然后另一条线,但是得到
hola
mundo
hello
word
Run Code Online (Sandbox Code Playgroud)
因为我可以要求结果直到换行而不是每个空格?
所有
我的问题是下一个,我尝试用一些变量来评估列表,使用let来赋值给这个变量
如果我这样做(def a (list * 'x 'y))
,(let [x 3 y 3] (eval a))
我有一个CompilerException java.lang.RuntimeException:无法在此上下文中解析符号:x,编译:(NO_SOURCE_PATH:6)
但如果我跑了
(def x 4) (def y 4)
,(eval a)
我有一个16,无论如何,如果我再次跑(let [x 3 y 3] (eval a))
,我有16,
存在一种正确绑定x和y并评估列表的方法?
TY!
我正在编写一个接收数字l的方法,并返回一个带有随机数的大小为l的向量.我有这个代码,但不起作用
#include <time.h>
int makea (int z) {
int a1[z];
int i;
for (i = 0; i < tam; i++) {
a1[i]=srand(time(0));
}
return a1;
}
Run Code Online (Sandbox Code Playgroud)
这些是编译器返回的错误
arrays1.c:在函数'makea'中:
arrays1.c:12:错误:void值不被忽略,因为它应该是
arrays1.c:14:warning:return使用指针生成整数而不使用
强制转换array1.c:14:warning :function返回局部变量的地址
我认为这是指针的问题......但我不太确定