锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲电影唐人社一区二区,亚洲视频一区二区在线观看,精品日韩亚洲AV无码一区二区三区 http://www.tkk7.com/chaocai/category/52793.htmlzh-cnMon, 26 Nov 2012 07:17:44 GMTMon, 26 Nov 2012 07:17:44 GMT60The Clojure Program To solve N Queens Problem (Without back tracing)http://www.tkk7.com/chaocai/archive/2012/11/26/Clojure.html瓚呰秺宸呭嘲瓚呰秺宸呭嘲Mon, 26 Nov 2012 04:21:00 GMThttp://www.tkk7.com/chaocai/archive/2012/11/26/Clojure.htmlhttp://www.tkk7.com/chaocai/comments/391968.htmlhttp://www.tkk7.com/chaocai/archive/2012/11/26/Clojure.html#Feedback0http://www.tkk7.com/chaocai/comments/commentRss/391968.htmlhttp://www.tkk7.com/chaocai/services/trackbacks/391968.htmlThe following solution not using the back tracing way is more concise and readable, but for the searching space becomes huger, the performance is much worser then the previous one.

(ns SICP.unit3)
(defn conflictInCol? [s col]
  (some #(= col %) s)
)

(defn conflictInDia? [s col]
  (let [dia (count s)
        n1 (fn [c
] (Math/abs (- dia (.indexOf s c))))
        n2 (fn [c] (Math/abs (- col c)))]
    (some #(= (n1 %) (n2 %)) s)
  )
)

(defn safe? [s col] 
  (not (or (conflictInCol? s col) (conflictInDia? s col)))
)
  
(defn next-level-queens [solutions-for-prev-level board-size current-level]
  (let [solutions (atom [])]
    (doseq [s solutions-for-prev-level]
      (doseq [col (range 0 board-size)]
        (if (safe? s col)
          (reset! solutions (cons (conj s col) @solutions))
     
        )
       )
   
    )
   
      (if (< current-level (dec board-size))
        (recur @solutions board-size (inc current-level))
        (count @solutions)
      )
   )
)

(defn queens [board-size]
  (next-level-queens  (apply vector (map #(vector %) (range 0 board-size))) board-size 1)
)

Chao Cai (钄¤秴錛?br />Sr. SDE
Amazon


 

]]>
Clojure XPathhttp://www.tkk7.com/chaocai/archive/2012/10/15/ClojureXPath.html瓚呰秺宸呭嘲瓚呰秺宸呭嘲Mon, 15 Oct 2012 02:15:00 GMThttp://www.tkk7.com/chaocai/archive/2012/10/15/ClojureXPath.htmlhttp://www.tkk7.com/chaocai/comments/389555.htmlhttp://www.tkk7.com/chaocai/archive/2012/10/15/ClojureXPath.html#Feedback0http://www.tkk7.com/chaocai/comments/commentRss/389555.htmlhttp://www.tkk7.com/chaocai/services/trackbacks/389555.html
The functions to support using XPath in Clojure.

Source Code

 1 ;The code was implemented by caichao@amazon.com
 2 ;You could use the code anyway, but should keep the comments
 3 ;Created 2012.10
 4 (ns clojure.ccsoft.xml
 5   (:require [clojure.xml :as xml]))
 6  
 7 (import '(java.io StringReader)
 8         '(java.io ByteArrayInputStream))
 9  
10 (defn xml-structure [xml-txt] 
11    [ (xml/parse (-> xml-txt
12               (.getBytes)
13               (ByteArrayInputStream.)
14      )
15     )]
16 )
17  
18 (defn node [tag xmlStruct]
19  
20   (first (filter #(= (:tag %) tag) (:content xmlStruct)))
21 )
22  
23 (defn node [path xml-txt]
24    (loop [path path 
25           xml-content (xml-structure xml-txt) 
26           ]
27       (let [current-tag (first path) current-elem (first xml-content)]
28         (if (= (:tag current-elem ) current-tag)
29  
30           (if (= (count path) 1)
31             current-elem 
32             (recur  (rest path) (:content current-elem ))
33           )
34           (if (> (count  xml-content) 1)
35            (recur path  (rest xml-content))
36           )
37         )
38      )
39     )
40  )

How to Use

(def cmd-example "<command>
                   <header>
                     
<type>script</type>
                     
<transaction_id>12345</transaction_id>
                   
</header>
                   
<body>
                      println 
3+4;
                   
</body>
                  
</command>")
 
 
(node [:command :header :transaction_id] cmd
-example)




]]>
主站蜘蛛池模板: a视频在线观看免费| 一级免费黄色大片| av无码国产在线看免费网站| 亚洲成av人片在线观看无码不卡| 精选影视免费在线 | 亚洲日韩国产精品第一页一区| 国产成人无码精品久久久久免费 | 天天摸夜夜摸成人免费视频| 国产精品亚洲精品观看不卡| 欧美男同gv免费网站观看| 亚洲熟女www一区二区三区| 日韩a级毛片免费观看| 日韩精品视频在线观看免费| 亚洲精品WWW久久久久久| 永久免费A∨片在线观看| 久久久亚洲欧洲日产国码是AV| 18国产精品白浆在线观看免费 | 亚洲AV无码AV吞精久久| 亚洲A∨精品一区二区三区| 精品一区二区三区高清免费观看 | 中文无码成人免费视频在线观看| 亚洲第一福利网站| 免费大片黄在线观看yw| 亚洲av第一网站久章草| 激情综合色五月丁香六月亚洲| 日韩精品在线免费观看| 亚洲国产精品一区二区久| 永久免费看bbb| 二个人看的www免费视频| 亚洲色偷偷av男人的天堂| 在线免费观看色片| sss日本免费完整版在线观看| 亚洲国产高清人在线| 在线观看亚洲免费| 国产无遮挡裸体免费视频在线观看 | 久久成人免费电影| 亚洲啪AV永久无码精品放毛片| 亚洲日韩国产精品乱| 91福利视频免费| 免费无码国产在线观国内自拍中文字幕 | 91亚洲国产成人精品下载|