我创建了一个名为my-stuff的项目并添加到project.clj中,所以它看起来像这样
(defproject my-stuff "0.1.0-SNAPSHOT"
:description "Testing lein"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.5.1"] [clj-http "0.5.5"]]
:main my-stuff.core)
Run Code Online (Sandbox Code Playgroud)
所以我可以运行核心但是当我尝试运行lein run时我得到了这个
Learning\my-stuff>lein run
Exception in thread "main" java.lang.Exception: Cannot find anything to run for:
my-stuff.core
at user$eval5.invoke(form-init5159589073116828284.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6619)
at clojure.lang.Compiler.eval(Compiler.java:6609)
at clojure.lang.Compiler.load(Compiler.java:7064)
at clojure.lang.Compiler.loadFile(Compiler.java:7020)
at clojure.main$load_script.invoke(main.clj:294)
at clojure.main$init_opt.invoke(main.clj:299)
at clojure.main$initialize.invoke(main.clj:327)
at clojure.main$null_opt.invoke(main.clj:362)
at clojure.main$main.doInvoke(main.clj:440)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:419)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)
\Clojure\Learning\my-stuff>
Run Code Online (Sandbox Code Playgroud)
甚至核心确实存在于源中.
我该怎么办?
例如,如果我想将具有多个带括号的组的字符串解析为包含每个组的字符串列表
"((a b c) a b c)"
Run Code Online (Sandbox Code Playgroud)
成
["((a b c) a b c)","( a b c)"]
Run Code Online (Sandbox Code Playgroud)
我怎么用parsec做到这一点?使用between看起来不错,但似乎不可能用开始和结束值分开.
如果我有一个像......的列表
(def test [[1 2 3]
[4 5 6]
[7 8 9]])
Run Code Online (Sandbox Code Playgroud)
我希望索引为5(这将是(1,1))我该怎么做?所以(找到5个测试)=(1,1)
如果我有一个单词的向量,例如["john""说"......"john""走了"......]我想制作每个单词的哈希映射和下一个单词的出现次数,例如{"john"{"说"1"走了"1"踢了"3}}
我想出的最好的解决方案是通过索引递归遍历列表并使用assoc来继续更新哈希映射,但这似乎非常混乱.有没有更惯用的方法呢?
explandDol :: String -> String -> [String] -> IO String
explandDol conclusion operators atoms =
let (ys,zs) = splitAt (head (take 1 replacement)) conclusion in ys ++ getConclusion operators atoms ++ (tail zs)
where replacement = elemIndices '$' conclusion
getConclusion :: String -> [String] -> IO String
getConclusion operators atoms =
runRVar (choice [atom1 ++ " " ++ [operator] ++ " " ++ atom2 | atom1 <- atoms, atom2 <- atoms, operator <- operators,checkAtoms atom1 atom2]) StdRandom
Run Code Online (Sandbox Code Playgroud)
有没有好办法解决这个问题?我收到此错误:
/home/joe/Documents/haskell/LAG/main/main.hs: line …Run Code Online (Sandbox Code Playgroud) 我一直在经历clojure练习的喜悦,并且遇到了这个例子
(defn build-contract [c]
(let [args (first c)]
(list
(into '[f] args) ;; here is where i am confused
(apply merge
(for [con (rest c)]
(cond (= (first con) :require)
(assoc {} :pre (vec (rest con)))
(= (first con) :ensure)
(assoc {} :post (vec (rest con)))
:else (throw (Exception. (str "Unkown tag " (first con)))))))
(list* 'f args)))) ;; and here
(defn collect-bodies [forms]
(for [form (partition 3 forms)]
(build-contract form)))
(defmacro contract [cg & forms]
(list* `fn cg (collect-bodies …Run Code Online (Sandbox Code Playgroud) 嘿所以我正在努力学习haskell并且我在编写程序时遇到麻烦,该程序要求我从终端中的用户收集Int.我怎么做这个我尝试过这样的事情
import Data.Char (digitToInt)
getArguments :: IO Int
getArguments =
do putStrLn "Enter the number of arguments you want to have"
arguments <- getChar
return (digitToInt arguments)
main :: IO()
main = do
putStrLn "Welcome to Random Argument Generator"
let x = getArguments
print x+1
Run Code Online (Sandbox Code Playgroud)
但这不起作用PLZ帮助!
我会怎么做,如果我希望把名单IntS,从而为[1,2,3]以["?","?","?"](所以如果有一个"1",把它变成了"∧"等...)