我做
print [1,2]
Run Code Online (Sandbox Code Playgroud)
但我希望打印输出格式为[1,2],而逗号后面没有额外的空格.
我需要一些"stdout"功能吗?`
在linux2上的Python 2.7.5+(默认,2013年9月19日,13:48:49)[GCC 4.8.1]
如何将这个有效的Common Lisp(SBCL v.1.2.3)代码的循环部分翻译成Clojure(v.1.6)?经过几个小时/几天没有结果,我有点沮丧.在某些地方,我认为我没有得到这种功能定位......
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Unconditional Entropy
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Probabilities
(setq list_occur_prob '()) ;; init
;; set probabilities for which we want to calculate the entropy
(setq list_occur_prob '(1/2 1/3 1/6)) ;;
;; Function to calculate the unconditional
;; entropy H = -sigma i=0,n (pi*log2(pi)
;; bits persymbol.
(setq entropy 0) ;; init
(setq entropy (loop for i in list_occur_prob
for y = (* (log_base2 i) i)
collect y
))
(setq entropy (* -1 (apply '+ entropy))) ;; change the …Run Code Online (Sandbox Code Playgroud)